Auto DNS resolving in Ubuntu 12.04 desktop

There has been a significant change since Ubuntu 12.04 on how to manage DNS resolving.

Any changes made manually to /etc/resolv.conf will be overwritten later by a DNS manager deamon called resolvconf.

If fact, /etc/resolv.conf becomes a symlink right now:

lrwxrwxrwx 1 root root 29 Apr 23 21:59 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

By default, it looks like this:

# 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 127.0.0.1

How to configure DNS configuration for static IP?

Use dns-nameservers in etc/network/interfaces

auto eth0
iface eth0 inet static
address ...
netmask ...
gateway ...
dns-nameservers 8.8.8.8 1.2.3.4

How to change/override default DNS configuration

Resolvconf deamon contain four files base, head, original, tail to help you override/change the default configuration. And they are all in resolv.conf format.

  • base: Used when no other data can be found
  • head: Header of default resolv.conf. The server inside will the first ones to check.
  • original: Just a backup of your original resolv.conf at the time of resolvconf is installed.
  • tail: entries appended at the end of resolv.conf. In some cases, upgrading from a previous Ubuntu release, will make tail a symlink to original

Resolvconf not working

If resolv.conf is not auto populated/changed/updated.

  1. make sure resolvconf is installed:

    sudo apt-get install resolvconf
    
  2. reconfigure resolvconf:

    sudo dpkg-reconfigure resolvconf
    

Disable resolvconf

Although this is not recommended, one cam disable resolvconf by makeing /etc/resolv.conf a regular file instead of a symlink.

References

DNS in Ubuntu 12.04

Improvement to DNS resolving in Ubuntu

Comments !