How to disable IPv6 on Linux?

Latest edited on 2023-11-13

To disable IPv6 on Linux, you can follow these steps based on your distribution:

Temporarily effective settings:

1. Open the terminal window.

2. Switch to the root user.

3. Type the following commands:

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

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

sysctl -w net.ipv6.conf.tun0.disable_ipv6=1


If you want to re-enable IPv6, type the following commands:

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

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

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

sysctl -p

Notice: It is worth noting that this method is temporarily effective and will become invalid after you restarting the device.

Permanently effective settings:

1. Open the terminal window.

2. Type the command:

sudo nano /etc/sysctl.conf

3. Scroll to the bottom of the file and add the following lines:

net.ipv6.conf.all.disable_ipv6 = 1

net.ipv6.conf.default.disable_ipv6 = 1

net.ipv6.conf.lo.disable_ipv6 = 1

net.ipv6.conf.tun0.disable_ipv6 = 1

4. Save and close the file.

5. Reboot your device.

6. To re-enable IPv6, remove the added lines from /etc/sysctl.conf and reboot your device.

Notice: This method is to modify the configuration file, and it will still be effective after restarting.


Please keep in mind that you should typically avoid permanently disabling IPv6, as it could lead to compatibility challenges. It's typically disabled temporarily for problem-solving needs.



Was this article helpful?

Thanks for your feedback!

Why wasn't this article helpful?