Fix slow DNS in Ubuntu


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 to time nslookup 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:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

It was suggested to change this to

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:

Hope it helps you :)