Ubuntu – resolv.conf keeps getting reset by something

networkingresolv.conf

I need help figuring out why my resolv.conf keeps changing to this, causing me to not be able to access the outside internet and only the local network:

$ cat /etc/resolv.conf
nameserver 192.168.16.1
domain localdomain
search localdomain

I thought I fixed it by getting rid of the loopback interface and adding in the eth0 interface in /etc/network/interfaces with the instructions on jontsai's posterous blog.

I've tried things like doing:

$ sudo ifconfig eth0 down
$ sudo ifconfig eth0 up
$ sudo /etc/init.d/networking restart
$ sudo dhclient

And then things would work temporarily, and eventually the nameserver in resolv.conf would get reverted again.

P.S. I also posted this on ubuntuforums.


Edit:
There is at least one other program besides NetworkManager that's writing to resolv.conf, and I know this because when I refresh NetworkManager, the resolv.conf file that gets generated has a comment that says # Generated by NetworkManager, and the version that it keeps changing to does not.

So I am trying this:

while true; do echo listening; lsof | grep /etc/resolv.conf; echo sleeping; sleep 1; done


Edit 2:

Adding output of files:

$ cat /etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

No such file as /etc/NetworkManager/NetworkManager.conf

$ sudo cat /etc/NetworkManager/system-connections/Auto\ Ethernet 

[connection]
id=Auto Ethernet
uuid=#######omitted#######
type=802-3-ethernet
autoconnect=true
timestamp=1314377063

[ipv4]
method=auto
ignore-auto-routes=false
ignore-auto-dns=false
dhcp-send-hostname=false
never-default=false

[802-3-ethernet]
speed=0
duplex=full
auto-negotiate=true
mtu=0

[ipv6]
method=ignore
ignore-auto-routes=false
ignore-auto-dns=false
never-default=false

Best Answer

You can make static additions to /etc/resolv.conf. Those additions could override the things that are being automatically added.

First, install the resolvconf package.

Then, press Alt+F2 and run gksudo nautilus. Open /etc/resolvconf/resolv.conf.d/head if you want to add to the start of the file; open /etc/resolvconf/resolv.conf.d/tail if you want to add to the end. Make your changes, save/close the files, and then run sudo resolvconf -u to apply the changes.

(Sorry that I don't remember if the settings at the start or end of the file have the highest priority.)