Fix slow DNS in Ubuntu

2012-06-28

Out of the blue my computer started to be sluggish as hell. I'm still not sure why this suddenly became a problem, but it did.

This post concerns a slow dns problem in Ubuntu 11.04, although I suspect you could apply this to other versions as well.

After some searching I learned about time (neato trick) and when I compared time nslookup google.com to time nslookup google.com 8.8.8.8 it was 2s vs 0.025s... What the?

After some more searching, I ended up on this thread which mentions a file called /etc/nsswitch.conf which contains an entry called hosts. For me this was set to:

Code:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

It was suggested to change this to

Code:
hosts: files dns wins mdns4_minimal [NOTFOUND=return] mdns4

and to reboot. I did and this worked for me. I have no idea what they mean, but I'm happy that it works now.

Also, during my search I found a tool called namebench. Maybe it helps you.

In case you don't know, there's a google dns that's easy to remember: 8.8.8.8

Hope it helps you :)