Resolv.conf getting reset on reboot

If you have been around Linux for any length of time, you know that you can statically define which DNS servers your computer uses for name resolution. This is not always the case in Ubuntu / Debian systems because of a package called dhcp3-client. If this package is in use on your system, you will notice that your resolv.conf file is reset every time the system reboots or the network interfaces are cycled. This is because dhcp3-client resets your resolv.conf file using the information provided by your local DHCP server.

In my case, I am running numerous tools from my box and I need these tools to be able to resolve names on my LAN using the DNS server on my LAN. There are a couple different ways to resolve this issue but I’ll show you the way that I like to handle this.

Make sure that you have the IP addresses of the DNS servers you want to use and drop to the command line and run: sudo nano /etc/dhcp3/dhclient.conf

Navigate down through all of the commented area and locate the request directive. You will need to enter in your DNS above the request line with the prepend command. Mine looks like this:

prepend domain-name-servers 10.10.10.11, 208.67.222.222;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu;

As you can see, you just need to add that line and as many DNS servers as you need. In this example I have chosen to use my internal DNS server and OpenDNS as a secondary. Make sure your syntax is correct, separate DNS servers with commas and end the line with a semi-colon.

–Himuraken

Leave a Comment

3 × 2 =