Oleg Puzanov

professional web developer blog

Improve DNS lookup time under Ubuntu 11.04

A lot of people complain about weird problems with DNS resolving speed under Ubuntu while surfing the Internet - it could takes a long time to access a new site, but when it is finally loaded, further browsing on that site is good. It doesn’t depends on the browser – Firefox, Google Chrome, Opera – load pages quite slowly for the first time. Besides, your network seems to be ok – ping time is acceptable, download speed is good.

Familiar situation?

There are a lot of solutions proposed on different blogs and forums – most popular among them are disabling ipv6 both in Ubuntu and FF, using alternative DNS resolution service (like Google Publis DNS), playing with MTU parameter of your connection, etc. But unfortunately, nothing works for me.

Finally, I found a solution for this problem. It was in nsswitch.conf - system databases and name service switch configuration file.

Try the following:

cat /etc/nsswitch.conf | grep hosts

Output will be like this:

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

It means, that first Ubuntu will check files records (like /etc/hosts), then wins, then mdns4_minimal and finally dns. These records were added by Samba, so everything what we should do is change their order to:

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

Reboot to apply changes.


Tagged as ,
  • http://www.unixtutorial.org/ Gleb Reys

    Знакомые грабли, у меня уже привычка после обновления пакетов всё проверять.

    А ещё приучаюсь системы обслуживать с помощью пост-установочной поддержки конфигов и пакетов – puppet называется.