Follow this step-by-step tutorial to learn how to disable IPv6 on Linux from the command line.
- Open the Terminal (pin 1).
- Type:
sudo su
and enter your password to act as root. - Type:
nano /etc/sysctl.conf
and press “Enter” to open the configuration file. Or, just use your favorite text editor to edit this file. - Add the following lines to the sysctl.conf file:
net.ipv6.conf.all.disable_ipv6 = 1; net.ipv6.conf.default.disable_ipv6 = 1; net.ipv6.conf.lo.disable_ipv6 = 1
For nano, press “CTRL+O” then “Enter” to save the modifications and “CTRL+X” to close the file. - In the Terminal type:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
and press “Enter”.
If the output is “1”, your have IPv6 already disabled and no further actions are required. If the output is “0”, follow the next steps. - Type:
sysctl -p
You should get something like this:
- Type:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
and press “Enter”.
Now you should get “1” as a result, which means you have successfully disabled IPv6.