Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] dhcpcd and dnsmasq
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3647
Location: Hamburg

PostPosted: Thu Jun 02, 2016 9:48 pm    Post subject: [solved] dhcpcd and dnsmasq Reply with quote

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 :
Code:
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
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu Jun 02, 2016 10:35 pm    Post subject: Re: dhcpcd and dnsmasq Reply with quote

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
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 829

PostPosted: Thu Jun 02, 2016 11:35 pm    Post subject: Reply with quote

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
Code:
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.
Code:
resolv-file=/etc/resolv.dnsmasq
resolv-file=/etc/ppp/resolv.conf
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3647
Location: Hamburg

PostPosted: Fri Jun 03, 2016 7:44 am    Post subject: Reply with quote

@cboldt:
yep, both are good hints !
Thx
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3647
Location: Hamburg

PostPosted: Fri Jun 03, 2016 8:02 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2583

PostPosted: Fri Jun 03, 2016 10:10 am    Post subject: Reply with quote

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"?
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 829

PostPosted: Fri Jun 03, 2016 10:31 am    Post subject: Reply with quote

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.

Code:
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.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3647
Location: Hamburg

PostPosted: Fri Jun 03, 2016 10:44 am    Post subject: Reply with quote

Yes, I solved/circumvent in the mean while by just putting
Code:
dhcp_wlp3s0="nodns"
in /etc/conf.d/net. If I'm traveling and need more, I'll manually edit resolv.conf then.
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 829

PostPosted: Fri Jun 03, 2016 11:31 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Sun Jun 05, 2016 9:46 pm    Post subject: Reply with quote

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)

Code:

nooption domain_name_servers

_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3647
Location: Hamburg

PostPosted: Sun Jun 05, 2016 10:38 pm    Post subject: Reply with quote

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)

Code:

nooption domain_name_servers
indeed :-D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum