How to disable IPv6 on Linux

If network troubleshooting leads you to believe there's an issue with IPv6, you may need to shut down that protocol on your Linux machines. Jack Wallen shows you how.

Image: iStock/ayagiz

IPv6 offers a much larger addressing scheme than IPv4, which is one of the many reasons why it was developed. However, I have seen rare instances in which IPv6 has caused network problems.

Since some hardware doesn't take advantage of IPv6 (and most admins are still working with IPv4), a temporary and easy solution is to disable IPv6; the protocol can be re-enabled when the time comes when the issue has been permanently resolved.

SEE: IPv6: The smart person's guide

If you have hardware that perfectly implements IPv6 and software that uses it correctly, this is a non-issue. But if you're having networking issues with Linux servers or desktops, and you've exhausted all possible areas, you might try disabling v6 of the network protocol.

I've had a few instances where communication between a Linux desktop and an ATT UVERSE router would constantly drop, and disabling IPv6 was the only solution that worked. After a while I would re-enable IPv6 to see if a router firmware update (and a desktop OS update) had solved the problem; in some instances, it solved the issue and IPv6 could remain enabled, though in other instances, IPv6 would have to be disabled again.

I'll show you how to disable IPv6 on a Linux machine. (Note: I recommend disabling IPv6 only when you've exhausted all other options. Also, you should consider this a temporary fix.)

Command line

You guessed it, we're going to be working with the command line. I'll show you how to disable IPv6 on Red Hat- and Debian-based distributions.

Here's how to disable the protocol on a Red Hat-based system:

  1. Open a terminal window.
  2. Change to the root user.
  3. Issue the command sysctl -w net.ipv6.conf.all.disable_ipv6=1
  4. Issue the command sysctl -w net.ipv6.conf.default.disable_ipv6=1

To re-enable IPv6, issue the following commands:

sysctl -w net.ipv6.conf.all.disable_ipv6=0

sysctl -w net.ipv6.conf.default.disable_ipv6=0

Here's how to disable the protocol on a Debian-based machine.

    1. Open a terminal window.

    2. Issue the command sudo nano /etc/sysctl.conf

    3. Add the following at the bottom of the file:

    net.ipv6.conf.all.disable_ipv6 = 1

    net.ipv6.conf.default.disable_ipv6 = 1

    net.ipv6.conf.lo.disable_ipv6 = 1

      4. Save and close the file.

      5. Reboot the machine.

      To re-enable IPv6, remove the above lines from /etc/sysctl.conf and reboot the machine.

      The caveats

      If you happen to use X Forwarding through ssh, disabling IPv6 can break this system. To fix that issue, you must open the /etc/ssh/sshd_config file and change the #AddressFamily any to AddressFamily inet. Save that file and restart sshd.

      If you use Postfix, you could encounter issues with the service starting. To fix this, you'll have to use an IPv4 loopback. Open the /etc/postfix/ file, comment out the localhost line, and add the IPv4 loopback like so:

      #inet_interfaces = localhost

      inet_interfaces =

      An imperfect solution

      This isn't a perfect solution, but sometimes you have to be creative in your troubleshooting. If you're encountering odd networking errors with Linux servers and desktops, try disabling IPv6 to aid you in your troubleshooting or to provide a temporary fix.

      Also see

      About Jack Wallen

      Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

      Editor's Picks