DNS Caching in Ubuntu Desktop

In a previous blog entry I described setting up a caching-only DNS server to speed up hostname resolution on Debian systems.  I’ve recently been playing with Ubuntu and noticed that this hack is not working.

Some investigation lead me to two blog entries.

I have found that I can continue to use my own bind9 setup (not wishing to learn about dnsmasq(8) today) by combining sugestions from the two blogs.

  1. Setup DNS caching server per my existing procedure for Debian
  2. edit /etc/NetworkManager/NetworkManager.conf and comment out (with a #) the line dns=dnsmasq
  3. edit /etc/resolvconf/resolv.conf.d/head and add the line nameserver=127.0.0.1
  4. sudo restart network-manager

Now test it:

mjl@hoppy:~$ time nslookup australia.gov.au
Server:        127.0.0.1
Address:    127.0.0.1#53

Non-authoritative answer:
Name:    australia.gov.au
Address: 205.239.168.12

real    0m0.630s
user    0m0.008s
sys     0m0.000s
mjl@hoppy:~$ time nslookup australia.gov.au
Server:        127.0.0.1
Address:    127.0.0.1#53

Non-authoritative answer:
Name:    australia.gov.au
Address: 205.239.168.12

real    0m0.012s
user    0m0.000s
sys     0m0.008s

The (real) time dropped from nearly 2/3 of a second to under 1/64 seconds!
Once again visiting sites with lots of DNS lookups is improved dramatically.

Advertisements