David Hurst

PHP/MySQL, REALbasic, Javascript Developer

Debian / Ubuntu very slow to resolve DNS (slow DNS resolution or lookup)

I had this problem the other day: two websites using identical code to collect RSS news feeds from identical sources. Website A loads its pages in about a second, whereas Website B takes up to 10 seconds. Go figure.

After I had thought about the problem for a while, and checked the codebase was identical, I decided the problem must be due to the server. Website A runs on a Red Hat Fedora machine, whereas Website B runs on a Debian server. It finally dawned on me that the server has to resolve the DNS for each RSS feed address, and I concluded (incorrectly) that as the two servers are on different networks, there must be a problem with name servers on the network. I tried swapping the name servers around in my network configuration, and even trying different servers - all to no avail.

A bit of Googling finally revealed that Debian switches on IPv6 by default, and then uses this before it uses IPv4 for DNS resolution. This problem won’t just be affecting servers, it will affect anyone using a Debian linux distribution, and this includes the very popular Ubuntu. So if you have slow website response on websites with external sources, or you are fed up with sitting waiting for your browser to resolve each address you type in, here is the solution:

There is a configuration file called “aliases” here: /etc/modprobe.d/aliases

In there you will find a line like this: alias net-pf-10 ipv6

Change it to: alias net-pf-10 off ipv6

Reboot the machine. If you are running a server with BIND, double check that your BIND server has come back online.

Done.

What I don’t understand, is why Debian should default to this configuration. IPv6 is a while away from widespread use, so why not at least provide an option in the install script for the OS so the user can make their own choice?

RSS 2.0 | Trackback | Comment

4 Responses to “Debian / Ubuntu very slow to resolve DNS (slow DNS resolution or lookup)”

  1. Felix Lange

    thank you very much. i’m running debian unstable and this has indeed solved the problem,
    although i had to uncomment the line first.

  2. Sasha Mrkailo

    Thanks a lot David, this helped although I don’t understand why. :)

  3. Sasha Mrkailo

    No, it seemed to work just for a moment, now its again not working.


  4. thank you very much

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>