Tuesday, May 21, 2013

HOWTO override DHCP resolv.conf nameserver setting on Debian Wheezy running Network Manager

Why run a DNS server on your laptop?

  • It is easy.
  • You are getting jerked around
    1. DNS built into the wireless access point is slow or broken
    2. Your ISP is evil and hijacks DNS

Evil is the big issue. DNS (Domain Name Service) translates names. for example, "howto.omacneil.org" should be IP# . An evil DNS server might send it to instead and show you a page of ads.


  • You are running Debian Wheezy (not tested with Ubuntu)
  • You use a dynamic (DHCP) address
  • You use Network Manager

If you are using a static IP address on one interface you can edit /etc/network/interfaces and set " dns-nameservers" for the interface in question.

With DHCP (via Network Manager), your computer connects to the network, sends a broadcast asking for an IP address. The DHCP (dynamc host configuration protocal ) server replies with an IP address, default gateway, nameserver(s) and other network information.

Your goal to over-ride nameserver that your ISP sends you via DHCP

These steps should work on Debian Etch/Squeeze/Wheezy , but I've tested them only on Wheezey

     # Install the DNS server
     sudo apt-get install bind9

     # install the package that lets you tell Network Manager 
     # what nameservers to use
     sudo apt-get install resolvconf

Add these lines to /etc/resolvconf/resolv.conf.d/head

  #    edit /etc/resolvconf/resolv.conf.d/* as appropriate

  # google's no cost , non-evil , free DNS server

  # copy of bind running locally the cache 
  # probably isn't as big as google's

Ignore the comment that tells you not to edit the file. The purpose is to tell you not to edit the generated /etc/resolv.conf file

If things don't work

  • Revert to your backed-up copy of /etc/resolvconf/resolv.conf.d/head
  • Consider DNSmasq

Other possibilities

Use the Network Manager GUI to edit each individual connection, one-at-a-time-tediously

  1. Right click the icon
  2. Edit Conections
  3. Wireless
  4. Double click <your connection name>
  5. IPv4 settings
  6. Change "Automatic (DHCP)" to "Automatic (DHCP) address only"
  7. set DNS Servers to: ''
  8. Save


Thanks to Thomas Hood for writing the resolvconf package

No comments:

Post a Comment