how to prevent dhcp modify /etc/resolv.conf

Asked by LI Daobing on 2007-02-11

Hello,

if I use following lines in /etc/network/interfaces:

auto eth0
iface eth0 inet dhcp

after each time I run "/etc/init.d/networking restart", /etc/resolv.conf is updated, which is not what I wanted, I want to use opendns instead of the dns provide by dhcp, which is bug-full.

please help me implement it, thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu ifupdown Edit question
Assignee:
No assignee Edit question
Solved by:
LI Daobing
Solved:
2007-02-11
Last query:
2007-02-11
Last reply:
2007-02-11

What is your dhcp server? Could you tell the dhcp server to give out the opendns server IPs rather than the broken ones?

Best LI Daobing (lidaobing) said : #2

I have found the answer on http://www.opendns.com/start/unix.php just now:

<quote>
Using OpenDNS with DHCP

If you assign your computer's IP with DHCP, it probably overwrites your /etc/resolv.conf. Here's how to fix that:

   1. Run: sudo gedit /etc/dhcp3/dhclient.conf
   2. Change the prepend line to read:

      prepend domain-name-servers 208.67.222.222, 208.67.220.220;

      This will prepend the OpenDNS addresses to the top of the list. (You can also use "supersede", which will just use them.) You don't have to worry about the DHCP client overwriting settings on each reboot or lease cycle, and your ISP nameservers will still be used as backup.
   3. Run: sudo /etc/init.d/networking restart
   4. Using Ubuntu? Check "Networking" to see if the changes applied correctly.
      Go to "System –> Administration –> Networking" and click the DNS tab.
</quote>