0

I have already read the very useful question about dhcpcd: How do I set up networking/WiFi/static IP address?

My situation seems to be slightly unusual:

  • DHCP server on LAN is set to always give the Pi a specific IP address (based on its MAC). Let's say 192.168.0.100.
  • The Pi is running bind, listening on 192.168.0.100:53.

I want to configure the Pi to still get its IP address via DHCP, but to force the primary DNS server to be 192.168.0.100 (itself).

I understand I should update /etc/dhcpcd.conf with: nohook resolv.conf

Is the "correct" way, on the Pi, to set the DNS server to:

  1. Add the DNS configuration to /etc/resolv.conf.tail, OR
  2. Add static domain_name_servers=... to /etc/dhcpcd.conf?

Are there any particular advantages or disadvantages to either method?

Also, I do not want to configure the DHCP server to give out 192.168.0.100 as the DNS server.

  • There is no "correct" way, because what you have described makes no sense. Are you running a DNS server on the Pi? Normally you would return the address of the DNS server/s or the gateway address (which is responsible for forwarding DNS requests). – Milliways Nov 10 '16 at 11:39
  • Hi @Milliways, thanks for the comment. I'm not quite sure why you think it doesn't makes sense? As I say in the post, the Pi is running the Bind DNS server so that's why I want to tell the Pi to use itself as the DNS server and also as I say in the post, I don't want to give out the Pi's IP address via DHCP (because I don't want other devices on the network to use the Pi as the DNS server). – Bridgey Nov 10 '16 at 11:51
  • I did not say this cannot be done, but normally the DHCP server does this job. If you want to do this (and I can't think of any reason why) you will have to work it out on your own - there will be no "correct" way. – Milliways Nov 10 '16 at 11:55
0

I think the answer you're looking for is here.

Blatantly plariarised:

You can add the following line to /etc/dhcp/dhclient.conf:

prepend domain-name-servers <working DNS IP(s) here>;

This adds the DNS IP address(es) you specify before that/those provided by the DHCP. If you would like to add it/them after the address(es) provided by the DHCP, just use

append domain-name-servers <working DNS IP(s) here>;

If, instead you would like to ignore the DNS address(es) provided by the DHCP altogether, use

supersede domain-name-servers <working DNS IP(s) here>;
  • Thank you very much for this - very helpful! I think this is for dhclient rather than dhcpcd, but I guess the principle is the same: specify it in he dhcp client configuration and it should get passed through to '/etc/resolve.conf'. I'll give it a while to see if anybody posts a dhcpcd-specific answer, but if not I'll accept yours. Thanks! – Bridgey Nov 10 '16 at 13:22
  • dhcpd is the DHCP server, isn't it? The thing which hands out IP addresses. That's not what you want to be running on your Pi if you have a router already doing it (which is what I interpreted from your post). dhclient is the DHCP client which goes to the DHCP server and gets an IP address (and other things). If you really are wanting the Pi to be the DHCP server, then that's a special case I don't know about -- how the DHCP server's IP address is allocated. – Mark Smith Nov 10 '16 at 13:31
  • dhcpcd - note the c :) This is a DHCP client not server :) This is currently the recommended DHCP client for the Pi (I believe!) – Bridgey Nov 10 '16 at 13:46
  • Ah! My mistake! :-) – Mark Smith Nov 10 '16 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.