# [solved] dhcpcd and dnsmasq

## toralf

I activated DNSSEQ for dnsmasq. Now I want just 127.0.0.1 in my /etc/resolv.conf. Therefore I'd like to change the behaviour of dhcpcd to no longer add nameserver=... to /etc/resolv.conf. It is my understanding  thet I need to tell dnsmasq those (at every change of dhcpcd too) to take the nameserver from it.

Theses 2 files looks like a good input for dnsmasq :

```
tfoerste@t44 ~ $ ls -l /var/run/dhcpcd/resolv.conf/wlp3s0.dhcp*

-rw-r--r-- 1 root root 98 Jun  2 18:07 /var/run/dhcpcd/resolv.conf/wlp3s0.dhcp

-rw-r--r-- 1 root root 76 Jun  2 18:07 /var/run/dhcpcd/resolv.conf/wlp3s0.dhcp6

```

So I wonder how to configure dnsmasq to poll both files and eats teh nameserver= from there ?Last edited by toralf on Fri Jun 03, 2016 11:37 am; edited 1 time in total

----------

## khayyam

 *toralf wrote:*   

> I activated DNSSEQ for dnsmasq. Now I want just 127.0.0.1 in my /etc/resolv.conf. Therefore I'd like to change the behaviour of dhcpcd to no longer add nameserver=... to /etc/resolv.conf. It is my understanding  thet I need to tell dnsmasq those (at every change of dhcpcd too) to take the nameserver from it.

 

toralf ... if serving DNS then provide the machine with a static address, no more dhcpcd, no need to change the dnsmasq config as and when the IP changes.

best ... khay

----------

## cboldt

Just for ease of maintenance, I put dnsmasq.conf material in a /etc/dnsmasq-local.conf file, and put a line in /etc/dnsmasq.conf

```
conf-file=/etc/dnsmasq-local.conf
```

You don't need to do that, and that line doesn't set nameservers, but when dnsmasq is upgraded, rather than have a bunch of changes to make to dnsmasq.conf, forever after, all you have to do is add that one line at the end of dnsmasq.conf.

Now, to get nameservers, you can have as many of these lines in dnsmasq.conf (or dnsmasq-local.conf) as you need.

```
resolv-file=/etc/resolv.dnsmasq

resolv-file=/etc/ppp/resolv.conf
```

----------

## toralf

@cboldt:

yep, both are good hints !

Thx

----------

## toralf

Which yields now tho the last question: How do I tell dhcpcd to not put "nameserver" entries into resolv-conf, but let it set the "domain" ?

And another thing: At my server I can activate "dnssec-check-unsigned" whereas at my desktop (at home in moment behind a ADSL-modem-router) I need keep that line being commented out.

----------

## charles17

 *toralf wrote:*   

> Which yields now tho the last question: How do I tell dhcpcd to not put "nameserver" entries into resolv-conf, but let it set the "domain" ?

 

Did you check man dhcpcd.conf for "resolv.conf"?

----------

## cboldt

I know little about the working of dhcpcd, but a quick peruse of the man pages led me to a couple potential avenues to stop its DNS pass-thorugh, which retaining the domain-name assignment.

```
man dhcpcd     #of course

man dhcpcd-run-hooks      #this was "news" to me
```

At any rate, "man dhcpcd" includes this ...

 *Quote:*   

> So to stop dhcpcd from touching your DNS settings you would do:-
> 
>                    dhcpcd -C resolv.conf eth0

 

"--nohook" is a synonym for the "-C" switch

A little more behind the scenes.

My system has a file at /lib/dhcpcd/dhcpcd-hooks/20-resolv.conf

The goal is to have dhcpcd run without invoking that script.

I'd put the dhcpcd "--nohook resolv.conf" switch in /etc/conf.d/net, which has facilities to add switches.

Another method is to modify /etc/dhcpcd.conf

From `man dhcpcd.conf` ...

 *Quote:*   

> So to stop dhcpcd from touching your DNS settings or starting wpa_supplicant you would do:-
> 
>                    nohook resolv.conf, wpa_supplicant

 

Edit to add this, which I found in my /etc/dhcpcd.conf file.  This would apply the change across all interfaces, which is perhaps not what you want ...

 *Quote:*   

> # A list of options to request from the DHCP server.
> 
> option domain_name_servers, domain_name, domain_search, host_name
> 
> option classless_static_routes

 

I'm thinking that removing "domain_name_servers" from the option list would result in the same behavior.

----------

## toralf

Yes, I solved/circumvent in the mean while by just putting 

```
dhcp_wlp3s0="nodns"
```

in /etc/conf.d/net. If I'm traveling and need more, I'll manually edit resolv.conf then.

----------

## cboldt

I think your dhcp_eth0="nodns" (in /etc/conf.d.net) is the best way to stifle dhcpcd.  Keep in mind that you can configure dnsmasq to choose between several "resolv.conf" type files.  The dnsmasq man page says that dnsmasq polls these files and uses the most recent one.  Just saying, you needn't edit /etc/resolv.conf if you want that to be static.  You could have a /etc/resolv.local or similar (polled by dnsmasq), and list nameservers there as any exceptional circumstance arises.

----------

## UberLord

 *toralf wrote:*   

> Which yields now tho the last question: How do I tell dhcpcd to not put "nameserver" entries into resolv-conf, but let it set the "domain" ?

 

I believe the nooption directive is documented in dhcpcd.conf(5)

```

nooption domain_name_servers
```

----------

## toralf

 *UberLord wrote:*   

>  *toralf wrote:*   Which yields now tho the last question: How do I tell dhcpcd to not put "nameserver" entries into resolv-conf, but let it set the "domain" ? 
> 
> I believe the nooption directive is documented in dhcpcd.conf(5)
> 
> ```
> ...

 indeed  :Very Happy: 

----------

