How to disable IPv6 permanently?
I successfully disabled IPv6 once putting the following lines in /etc/sysctl.conf
:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
also run this command to load changes
sudo sysctl -p
If your PC doesn't load /etc/sysctl.conf at boot time (which is the case for me), disabling IPv6 from grub is needed. Linux kernel has a boot option named "ipv6.disable=1" which disables IPv6 from startup.
To edit the boot options, edit "/etc/default/grub" with any text editor as root user:
sudo nano /etc/default/grub
Find the line that contain "GRUB_CMDLINE_LINUX_DEFAULT":
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Add "ipv6.disable=1" to the boot option, then save your grub file:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"
Finally, update grub:
sudo update-grub
Here's how to check to see if ipv6 is enabled on your computer
test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready"
If you see
Running kernel is IPv6 ready
it is enabled.
If you see no output, it is not.
To disable ipv6 if the other answers on this page don't work for you, blacklist ipv6 all-together. To do this, use the following command:
echo 'blacklist ipv6' | sudo tee -a '/etc/modprobe.d/blacklist.local' >/dev/null
Also, this might help as well:
echo 'install ipv6 /bin/true' | sudo tee -a '/etc/modprobe.d/blacklist.local' >/dev/null
Reboot for the changes to take effect. To check if it's enabled after startup run this command again:
test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready"
There should be no output.
Click here for info on how to disable IPV6 at boot.
Carvalho's answer including the comment about having to run sudo sysctl -p
has helped me the most.
However, in my case at least:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.<mydevice>.disable_ipv6 = 1
and it seems the second line was necessary.
Maybe this has to do with the fact that I am using the TP-Link Archer T2U, for which I had to customly build a driver from source.
My assumption is that as a result, <mydevice>
doesn't count as one of "all
".
So, in a nutshell, if you have customly added a (custom) networking driver, net.ipv6.conf.all.disable_ipv6 = 1
might not be sufficient to disable IPv6 networking.
Have to admit though, that I didn't try the line net.ipv6.conf.default.disable_ipv6 = 1
.
If you are using a modern version (I'm on 16.04 LTS) of Ubuntu then you can use this tidy solution:
Create /etc/sysctl.d/60-ipv6-disable.conf
containing the following text:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Run service procps start