How to Disable IPv6 on Linux

Want to know how to disable IPV6 on Linux? Here is a easy guide for you to disable IPv6 on linux.

Written By Lorenzo Vincent

Updated at January 2nd, 2024

Red Hat distributions

Here are the steps to disable the IPv6 on Red Hat distribution.

  • Open a terminal window.
  • Change to the root user.
  • Type these 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
 
  • For enabling IPv6 again you must type the below 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
 

Debian based distributions

Here are the steps to disable the IPv6 on Debian distribution.

  • Open a terminal window.
  • Type the below command:
sudo nano /etc/sysctl.conf
 
  • 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
net.ipv6.conf.tun0.disable_ipv6 = 1
 
  • Save and close the file.
  • Reboot the device.

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