How to Disable IPv6 in Ubuntu 16.04 Xenial Xerus

Internet Protocol version 6 (IPv6)

In the course of troubleshooting a pseudo-distributed mode installation of Apache Hadoop on my Ubuntu 16.04 vm, one of the tips I stumbled across suggested disabling IPv6.

For any networking neophytes, Internet Protocol version 6, aka IPv6, is the most recent version of the Internet Protocol (IP), the system governing the assignment of addresses to networks and computers on the Internet. IPv6 was created to replace IPv4 which, why still predominantly used by most systems, is quickly running out available addresses. Unlike IPv4, which is a 32 bit addressing scheme offering 2^{32} or roughly 4.3 billion addresses, IPv6 addresses are 128 bits, meaning that there are theoretically 2^{128} or roughly 3.4 \times 10^{38} addresses.

While IPv6 provides more than enough addresses to allow the Internet to continue to grow at its breakneck pace, the two protocols, IPv6 and IPv4, aren’t interoperable, and sometimes conflicts arise when both are active on the same computer. I’m honestly unsure yet whether or not IPv6 is causing my difficulties with Hadoop, but since I am not connected to an IPv6 network, there is not any reason for me to not disable it entirely.

UPDATE 2017-02-02: For a better solution than mine below, see Dave Bevan’s comment.

The steps to follow in order to disable IPv6 in Ubuntu 16.04 are:

  1. First check to see if IPv6 is already disabled. To do so, open up the Terminal, and at the command line enter: /proc/sys/net/ipv6/conf/all/disable_ipv6. If the return value is 1, then IPv6 is already disabled, and you are done. A return value of 0 indicates IPv6 is active, and you need to continue on to Step 2.

    Disable IPv6
  2. Open the file /etc/sysctl.conf in your text editor of choice. I chose to edit the file using Bluefish, but you can use vi, gedit, emacs, etc., but because the file is only writable by the root user (it should have 644 permissions), you will need to have superuser access in order to save your changes.

    Launching Bluefish as a superuser
  3. At the end of sysctl.conf, add the following three lines:
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    net.ipv6.conf.lo.disable_ipv6 = 1

    sysctl.conf

  4. Now run sudo sysctl -p to update to reconfigure the kernel parameters with the new values set in Step 3. The output of sysctl will be the parameters that have changed, so unless you made other edits to sysctl.conf, the output will simply be the lines you added above.

    sysctl -p
  5. If you run /proc/sys/net/ipv6/conf/all/disable_ipv6 now, it should now return 1 indicating that IPv6 has been disabled.

    Disable IPv6

16 comments

Skip to comment form

    • Tony on January 1, 2017 at 12:36 pm
      Author
    • Reply