I am running Debian 7 and have set up a DHCP and DNS server.

Everything is working nicely, except for the server itself not following the DNS entries in BIND.

The problem is that /etc/resolv.conf is populated by an upstream gateway as its primary DNS. After manually changing the entry to point to itself instead of the upstream gateway, the DNS server uses the BIND settings before requesting DNS from the gateway.

Unfortunately, upon reboot or re-connect of the interface, /etc/resolv.conf reverts back to using the gateway, putting me back into the problematic situation.

I'd like to keep dynamic IP on that interface, while using a static nameserver. Is this possible?


Add the following line to /etc/dhcp/dhclient.conf on your server:

prepend domain-name-servers;

This makes it prepend to whatever content of /etc/resolv.conf was forced on it by the gateway DHCP.

Why option domain-name-servers x.x.x.x doesn't work

From the dhclient.conf(5) man page:

The option statement is used to specify the value of an option supplied by the server, or, in the case of predefined leases declared in dhclient.conf, the value that the user wishes the client configuration script to use if the predefined lease is used.

  • I set option domain-name-servers x.x.x.x thinking that would do it. What'd the difference between 'option' and 'prepend'?
    – earthmeLon
    Nov 6 '13 at 22:51
  • 1
    @earthmeLon Please see the updated answer.
    – Joseph R.
    Nov 6 '13 at 22:59

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.