Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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

prepend domain-name-servers 127.0.0.1;

This makes it prepend 127.0.0.1 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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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