Disable IPv6 on Ubuntu to Speed Up Browsing

DNS LookupAre you a user of Ubuntu or variant of it? When you’re browsing the web, do websites seem to load incredibly slowly? Looking that the status bar of your browser, does it constantly say that its looking up a certain website?

This process is called DNS lookup. Whenever you visit a website, your computer needs to perform a DNS lookup on every domain and domain hosts (subdomains) that the site uses. On most websites, this could be dozens as many websites. techairlines.com, www.techairlines.com, and s.techairlines.com are different hosts, therefore three different DNS lookups.

DNS lookups translate the website URL to an IP address, which would direct your computer to connect to a certain server.

Normally, DNS lookups don’t take more than half a second and the extra load time can’t be noticable.

But if you’re on Ubuntu, you may notice that your browser looks up each domain for a long time, such as 30 seconds each.

What’s the Problem?

By default, Ubuntu has a setting to use IPv6 turned on. Many routers, such as my own, do not support the IPv6 protocol and for most people, its not needed. But since the setting is turned on, Ubuntu will try to use it anyway and attempt to use it when looking up websites.

Unfortunately, if your router doesn’t support it, this process doesn’t work and Ubuntu finally falls back to IPv4, which is when the DNS lookup is successful, or sometimes the site just won’t load.

But when it begins the next lookup, IPv6 is still enabled, so this starts again. The result? A horribly slow connection to websites.

The fix? Disable IPv6 of course!

The Easy Fix (Firefox Only)

Firefox IPv6If you only run Firefox, then you can just use the easy fix instead of editing system files.

Visit about:config in Firefox.

In the Filter box, type in the following string:

network.dns.disableIPv6

Double click on the result or right click on it and toggle it to True. Restart your browser and enjoy the faster speed!

The System-Wide Fix

If you use another browser or application that does not provide access to all the settings like Firefox does, you would have to change the setting system-wide.

First, check if IPv6 is enabled by running the following command. If the output is 0, it means its enabled. If it’s 1, then its disabled already.

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

You need to add the following lines to the file at /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Alternatively, you can just open up a terminal, elevate it with sudo, and run the following commands:

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

Restart your computer and then run the first command to check if its disabled. The output should be a 1.

Check IPv6

If the output of the command is 1, it means IPv6 is disabled.

For Firefox, you will still need to toggle the value explained in the above section.

Are you using Ubuntu and suffering from slow DNS lookups? Does this tutorial help solve your problem? Have another method? Share with us in the comments!

Liked this article? Share it with your friends.

By
Brian is the co-founder of TechAirlines. He is a developer currently focusing on mobile and web development. He is currently a sophomore at Stony Brook University, majoring in Computer Science.

  • http://techied.net TechGyani

    Thanks for the nice tutorial. :)

    To edit sysctl.conf run this command in terminal
    sudo gedit /etc/sysctl.conf to

  • http://tripideas.org/ Slava

    I don’t think it’s a good idea in a world scale. We’re running out of IPv4 addresses and migration to IPv6 is pretty unavoidable by now. Disabling it would mean you’d have to re-enable it quite soon (hopefully remembering where did you turn it off :) ). In short: leaving IPv6 on is good karma :)

    • http://www.techairlines.com Brian Yang

      Hi Slava,

      That is indeed true.

      My article was intended for individuals using Ubuntu who own older routers that simply don’t support IPv6 currently, such as my own. If a router supports IPv6 connections, then leaving it on would work just fine.

      Thanks for visiting,
      Brian

  • http://NicholasScalice.com Nicholas Scalice

    Thank you for this very informative info! Just another reminder of why I like Chrome.

  • http://bredsaal.dk/ Jannich

    Another solution would be to install and use an IPv6 tunnel service, like the miredo package. :-)

  • Don Christensen

    On a Maverick system, I modified my /etc/sysctl.conf as above and noticed this in the /etc/sysctl.d/README file:

    ‘After making any changes, please run “start procps”.’

    I did that and it seems to have applied the changes. No more AAAA DNS requests, without rebooting. IPv6 shows as disabled. Nice.

  • Mark S

    It doesn’t work on Ubuntu 10. I have ipv6 disabled in /etc/sysctl.conf and now I don’t even have ipv6 anywhere in /proc. Everything except Firefox is still trying to do DNS lookups of AAAA records and waiting for multiple timeouts before connecting.

    I’m still waiting for ipv6 to solve a problem – so far, it only breaks things for me… :(

  • http://mcgi.org Arnold Martin

    Sir, I would like to ask if you know any multi-threaded, IDM-like downloader for Ubuntu? TIA Best Regards
    Arnold

  • Jean Debogue

    I agree that my first experience with firefox and ipv6 was that it’s true it seems some sites are slower. It felt like the SSL enable sites were in general slower.

    I did some research and this https://kb.wisc.edu/cae/page.php?id=10985 found the solution to it.

    The browser check the validity of SSL certificates and if ipv6 is enable it will try to reach those agencies to verify the authenticity.

    The problem is that they are not ipv6 enable. So it times out and it feels like nothing is happening.

    So we need to upload a list of domains to not use these with ipv6.

    Browse to config:about and look for this key
    network.dns.ipv4OnlyDomains

    The copy/paste this list. http://www.wedebugyou.com/ipv4domains.txt

    If you are still timing out, you can also find the dns queries that are timing through a packet capture on port 53. Let me know if you need more explanations.

    For me since I put that list the browsing experience with ipv6 and firefox is much better.

    Jean
    http://www.wedebugyou.you

  • acelite

    i have a problem. its not fixed :(

  • http://www.facebook.com/AkashKumar6911 Akash Kumar

    it work :) thank you..