There are times when you wish IPv6 is not active on your system. When that’s the case you may be able to disable it using one of the methods below.
But first, check to be sure that it is indeed activated on your machine. The following instruction allows you to do just that. Run it in a terminal window:
This command will show you your network configuration status and might include a line (or more) starting with:
inet6 addr: fe80::21c:…
If that’s the case it means that IPv6 is indeed present on your system. If no such line comes up then your machine is clear of IPv6. Therefore you don’t need to do anything more.
Now, if IPv6 is present and you wish to disable it permanently follow the following steps:
(Note: $ indicates a command line prompt and should not be typed in)
1) Permanent shut off via sysctl
Edit the file /etc/sysctl.conf with gedit or nemo
$ sudo gedit /etc/sysctl.conf
And insert following block of 5 lines at the end of the file:
# — Following 3 lines are used to disable IPv6 on this machine —
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
# — Above 3 lines are used to disable IPv6 on this machine —
Then issue the following command to restart sysctl:
$ sudo sysctl -p
You’re done! IPv6 is now permanently disabled on your machine.
You can also achieve the same result using a second method:
2) Permanent shut off via GRUB
IPv6 can also be disabled by editing the grub configuration file using one of the editors mentioned earlier:
$ sudo gedit /etc/default/grub
Look for the line containing “GRUB_CMDLINE_LINUX”
and edit it as follows:
The same can also be added to the value of the variable named
“GRUB_CMDLINE_LINUX_DEFAULT” and either would work.
Save the file, close it and regenerate the grub configuration
$ sudo update-grub2
Then, reboot your computer. Henceforth, IPv6 should be disabled.
Alternatively, you may want to disable IPv6 only temporarily, for the duration of your current session, so that when you reboot your computer again IPv6 remain intact. In that case use the following scheme:
3) Temporary IPv6 shut off via sysctl
The kernel parameters that enable IPv6 can be temporarily turned off using the following commands:
$ sysctl net.ipv6.conf.all.disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 0
$ sysctl net.ipv6.conf.default.disable_ipv6
net.ipv6.conf.default.disable_ipv6 = 0
$ sysctl net.ipv6.conf.lo.disable_ipv6
net.ipv6.conf.lo.disable_ipv6 = 0
The outcome of the above action can also be checked from the proc files:
$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
$ cat /proc/sys/net/ipv6/conf/default/disable_ipv6
$ cat /proc/sys/net/ipv6/conf/lo/disable_ipv6
And, in the same fashion they could be written-in the value of 1 or 0 to disable or enable:
4) Temporary IPv6 shut off via proc files
Note that the variables control “disabling” of IPv6.
Therefore, setting them to 1 would disable IPv6, and to 0 enable it.
$ echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
$ echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
$ echo 1 > /proc/sys/net/ipv6/conf/lo/disable_ipv6
Using the method #4 with ‘echo 0 > /proc/sys/net/ipv6/conf/…’ you could reactivate IPv6 which was temporarily turned off on your machine.
(© cilicia.us – originally published on January 3, 2016)