Ubuntu – Static ip but dynamic nameservers

13.04dhcpdnsresolvconfstatic-ip

Trying to change nameserver' settings for a Ubuntu-13.04 server I came upon this situation!

/etc/network/interfaces :

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address    192.168.1.100
    netmask    255.255.255.0
    gateway    192.168.1.254
    dns-nameservers 10.1.1.20, 8.8.8.8
    dns-search null.local

/etc/resolv.conf :

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.1.1.20
nameserver 8.8.8.8
search null.local

… so I had to change the DNS addresses…

dns-nameservers 10.1.1.21 10.1.1.22

… and then recycle eth0 for the network configuration to rebuild itself :

~$ sudo ifdown eth0 && sudo ifup eth0

But this is the /etc/resolv.conf I get :

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 172.31.0.5
nameserver 10.1.1.21
nameserver 10.1.1.22
search wth.local null.local

FYI, 172.31.0.5 is in a "neighbor" network, apparently a DNS/DHCP server for the 'wth.local' domain I have no access to which "leaks" on my side! (this situation is temporary, but for now it has to stay that way)

What I can't explain and wish to understand is why? Why, if I specifically configure a static interface a DHCP process comes and messes with DNS? This is one server, I made the same changes on two others without any problems.

Best Answer

Found it!

Since a Ubuntu server autoconfigure itself via DHCP on installation it creates the file /run/resolvconf/interface/eth0.dhclient with the information about the wth.local domain :

domain wth.local
nameserver 172.31.0.5

Configuring a static IP won't delete the file and when you restart the network with the following command :

~$ sudo ifdown eth0 && sudo ifup eth0

, the DNS handler rebuild its resolv.conf file with both eth0.dhclient and eth0.inet files!

My guess is that the SA before me didn't bother and just edit the resolv.conf file; I had the problem on 1 server out of 3, thought it was a bug with 13.04 but I've replicated the same with a fresh 14.04 install...

Case closed!