Results 1 to 6 of 6
I have an annoying problem. Since I stopped using pppoe in Ubuntu and just used my existing router connection, some startup script or other keeps editing my resolv.conf so that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-28-2008 #1
[SOLVED] Something keeps editing my resolv.conf file
I have an annoying problem. Since I stopped using pppoe in Ubuntu and just used my existing router connection, some startup script or other keeps editing my resolv.conf so that the router is named as the nameserver. Result: my browser doesn't work. I have to copy back by hand the version of the file with the correct namesavers (which I keep saved under another name).
As far as I can see, the only script which could be doing this is the dhclient script which I assume is run by ifup (eth0 is specified as dhcp). I tried changing /etc/network/interfaces to make eth0 static so that dhclient wouldn't run (I used the address and mask that my router normally allocates to it) but then it failed to come up at all.
How do I stop this joker from messing up my configuration?"I'm just a little old lady; don't try to dazzle me with jargon!"
- 07-28-2008 #2
You can edit dhclient.conf to alter this behavior.
Mine has
because I run a caching nameserver on the local host.Code:prepend domain-name-servers 127.0.0.1;
Prepend whatever server you want to appear at the
top of /etc/resolv.conf
- 07-30-2008 #3
I tried that but it makes no difference. I still ended up having to do it by hand.
"I'm just a little old lady; don't try to dazzle me with jargon!"
- 07-30-2008 #4Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,722
When you are using DHCP, the default config is to let the DHCP script modify the resolv.conf with values received from the DHCP server.
Where you disable/enable this varies by distro - I am sure Ubuntu's options are documented on Ubuntu's site or searchable on Google.
Reading openSuSE's dhclient-script file, I can see that that settings are available in:
/etc/sysconfig/network/config
/etc/sysconfig/network/dhcp
From /sbin/dhclient-script:
Code:make_resolv_conf() { # first, look if we are allowed to modify resolv.conf: eval `grep "^MODIFY_RESOLV_CONF_DYNAMICALLY=" /etc/sysconfig/network/config` eval `grep "^DHCLIENT_MODIFY_RESOLV_CONF=" /etc/sysconfig/network/dhcp` test "$MODIFY_RESOLV_CONF_DYNAMICALLY" = no \ -o "$DHCLIENT_MODIFY_RESOLV_CONF" = no \ && return # It might be useful to have more than one domain in the searchlist. To # achieve this set DHCLIENT_KEEP_SEARCHLIST in /etc/sysconfig/network/dhcp to "yes" # and put the additional domains in the searchlist of the *unmodified* # /etc/resolv.conf. When the client is configured via DHCP the old # searchlist will be appended to the new one. oldsearchlist="" eval `grep "^DHCLIENT_KEEP_SEARCHLIST=" /etc/sysconfig/network/dhcp` if test "$DHCLIENT_KEEP_SEARCHLIST" = yes ; then oldsearchlist=`while read line; do case $line in search*) oldsearchlist=${line/search /};; esac; done< /etc/resolv.conf; echo -n $oldsearchlist` fi
- 07-30-2008 #5
edit /etc/resolv.conf so it has the right information, then
now the file is no longer able to be modified, even by rootCode:sudo chattr +i /etc/resolv.conf
- 07-31-2008 #6
Thanks, that's just what I needed. According to my dhcp man pages, the Ubuntu way to do it is to create a script in /etc/dhcp3/dhclient-enter-hooks.d that redefines the make_resolv_conf function (which the dhclient script uses to edit the resolv.conf file). So I redefined the function to run true and exit and now the file is no longer modified.
The coopstahl3 solution is even simpler of course but it seems just a little bit like cheating!"I'm just a little old lady; don't try to dazzle me with jargon!"




