I'm looking to permanently disable IPv6 on a specific interface because it's broken and my question on Superuser to fix it is dead so how can I go about doing that? I've added net.ipv6.conf.eth0.disable_ipv6=1
to /etc/sysctl.conf
but it doesn't work for some reason. At the moment I just use the sysctl command every time I turn on my PC to disable it.
2 Answers
First, edit /etc/default/grub and find the line:
GRUB_CMDLINE_LINUX=""
and change the line to say this instead (this will disable ipv6 completely):
GRUB_CMDLINE_LINUX="ipv6.disable=1"
alternatively, to leave the ipv6 stack functional but to disable assignment of ipv6 addresses you can use the following option instead:
GRUB_CMDLINE_LINUX="ipv6.disable_ipv6=1"
Finally, run:
sudo update-grub
and reboot to apply the changes.
This will disable ipv6 at the kernel level so that it is never enabled from the get-go.
Also, after making the following changes to /etc/sysctl.conf
net.ipv6.conf.eth0.disable_ipv6 = 1
Run the following command to apply the changes:
sudo sysctl -p
Finally, if using the option to disable ipv6 in sysctl.conf, you need to also make sure ipv6 is commented out in /etc/hosts. See here https://wiki.archlinux.org/index.php/IPv6#Disable_functionality
-
1
-
@michas using
ipv6.disable_ipv6=1
instead ofipv6.disable=1
does not completely disable ipv6, it just prevents ipv6 address assignment. wiki.archlinux.org/index.php/IPv6#Disable_functionality– mchidMar 14, 2015 at 21:51
Neither the grub nor the sysctl solution worked for me. My guess is that systemd reenabled ipv6 during boot.
So I changed systemd to only configure ipv4 for my en*
devices:
sudo vim /etc/systemd/network/en-all.network
[Match]
Name=en*
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv4
up sysctl -w net.ipv6.conf.$IFACE.disable_ipv6=1
in the /etc/interface filenet.ipv6.conf.eth0.disable_ipv6 = 1
instead ofnet.ipv6.conf.eth0.disable_ipv6=1