IPv6 offers a much broader addressing scheme than IPv4, which is one of the many reasons it was developed. However, I have seen rare cases where IPv6 has caused network problems.
Since some hardware does not take advantage of IPv6 (and some administrators may be working with IPv4), a simple temporary solution is to disable IPv6. The protocol can be re-enabled when the issue has been permanently resolved.
If you have hardware that perfectly implements IPv6 and software that uses it correctly, this is not a problem. But if you are having network problems with Linux servers or desktops and have exhausted all possible areas, you can try disabling network protocol version 6.
I've had a few cases where communication between a Linux desktop and an old router was constantly dropping, 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 resolved the issue. In some cases it resolved the issue and IPv6 could remain enabled, although in other cases IPv6 would have to be disabled again.
I will show you how to disable IPv6 on a Linux machine. (Note: I recommend disabling IPv6 only when you have exhausted all other options. Also, you should consider this as a temporary solution.)
SEE: Top commands Linux administrators should know (TechRepublic Premium)
command line
You guessed it: we're going to work with the command line. I will 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:
- Open a terminal window.
- Switch to the root user.
- Issue the command sysctl -w net.ipv6.conf.all.disable_ipv6=1
- 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.
- Open a terminal window.
- Issue the command sudo nano /etc/sysctl.conf
- Add the following to the end of the file:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
- Save and close the file.
- Restart the machine.
To re-enable IPv6, remove the previous lines from /etc/sysctl.conf and restart the machine.
SEE: How to view your SSH keys on Linux, macOS, and Windows (TechRepublic)
The warnings
If you use X Forwarding over ssh, disabling IPv6 can break this system. To fix that problem, you need to open the /etc/ssh/sshd_config file and change the #FamilyAddress anyone to AddressFamily inet. Save that file and restart sshd.
If you use Postfix, you might have problems starting the service. To solve this problem, you will need to use an IPv4 loopback. Open the /etc/postfix/main.cf file, comment out the localhost line and add the IPv4 loopback like this:
#inet_interfaces = localhost
interfaces_inet = 127.0.0.1
SEE: How to set temporary environment variables in Linux (TechRepublic)
An imperfect solution
This is not a perfect solution, but sometimes you have to be creative when solving problems. If you encounter strange network errors with Linux servers and desktops, try disabling IPv6 to assist in troubleshooting or to provide a temporary solution.
This article was originally published in June 2016. It was updated in January 2025 by Antony Peyton.