Pranjal Das

Electric Design Engineer | Dastur | Kolkata, India


Enable or Disable IPv6 in Linux

In this blog we will see how to make persistent changes to IPv6 protocol in your Linux computer
Published July 17, 2024 | 3 min

Disabling IPv6 on a Linux computer can be done for several reasons. While IPv6 is the future of networking, there are situations where disabling it might be beneficial, like

  • Network Compatibilty Issues
  • Performance Issues
  • Security Concerns
  • Lack of ISP Support

In these cases disabling IPv6 might help. In this blog it is demonstrated how one can change the IPv6 settings temporarily or permanenetly

Disable IPv6

IPv6 can be disabled for a temporary period, and on the next restart the settings will set to the previous default settings. But this change can also be made persistent by modifying the config file, which will allways keep the IPv6 disabled unless you enable it again

Disable IPv6 Temporarily

To disable IPv6 for a temporary period of time, the following commands will do the work

For All Network Interfaces
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
For a Specific Network Interface
sudo sysctl -w net.ipv6.conf.{eth0}.disable_ipv6=1

Where you need to Replace {eth0} with the interface name for which you want to disable the IPv6

Disable IPv6 Permanently

To disable IPv6 permanenetly we need to make some modifications on the file /etc/sysctl.conf, or a new file can be created at /etc/sysctl.d/sysctl.conf where the changes can be made, without modifying the original sysctl.conf file

But here I will put the modifications in the original file, so lets open the file with nano

sudo nano /etc/sysctl.conf

Then the following lines can be added to file to permanenetly disable the IPv6

For All Network Interfaces
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
For a Specific Network Interface
net.ipv6.conf.{eth0}.disable_ipv6=1

To apply the changes we can run

sudo sysctl -p

Which will load all the changes made on the file /etc/sysctl.conf or the files in the directory /etc/sysctl.d/

Enable IPv6

Though IPv6 sometimes may create some problem but it is the future, it has larger address space, if configured properly IPv6 is more secure, supports SLAAC allowing devices to automatically configure their own IP addresses without the need for a DHCP server, does not require NAT and almost all modern protocols and applications are designed to work over IPv6. So it might be a good idea to enable IPv6 in your computer

Now enableing IPv6 is just the same process as disabling it, but the values are just changed from 1 to 0

Enable IPv6 Temporarily

For all Network Interfaces
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
For a Specific Network Interface
sudo sysctl -w net.ipv6.conf.{eth0}.disable_ipv6=0

Enable IPv6 Permanently

For All Network Interfaces
net.ipv6.conf.all.disable_ipv6=0
net.ipv6.conf.default.disable_ipv6=0
For a Specific Network Interface
net.ipv6.conf.{eth0}.disable_ipv6=0

To apply the changes, reload sysctl with the command

sudo sysctl -p

Conclusion

In this blog it is explained how one can change the IPv6 settings of their computer either temporarily or permanenetly, it is fairly straight forward to do so using the shown commands. I hope this blog will be helpful to people.