DescriptionThis page covers how to permanently disable IPv6 in Ubuntu Server. Given the complexities with managing a dual stack of IPv4 and IPv6, I recommend to disable IPv6 unless you have a specific requirement to run it. For a simple home server behind a NAT box, IPv6 is added complexity and only serves to complicate matters.
- A working ubuntu system
ConfigurationTo disable IPv6, you can do one of two things, either edit the sysctl.conf file or disable directly in grub. If you are only disabling temporarily or on a per interface basis, you can edit the sysctl.conf file. Otherwise, go the route of disabling it via grub. See below for both options.
Option 1Open /etc/sysctl.conf using a text editor.
sudo nano /etc/sysctl.confThen insert the following lines at the end of the file:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Option 2Open /etc/default/grub (default config file for grub).
sudo nano /etc/default/grubThen change the following line (if it already contains any options, leave those and insert ipv6.disable=1 at the beginning of the field.
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"Finally, you need to re-generate grub.
TestingTo verify that IPv6 was disabled, we can check the contents of the following.
cat /proc/sys/net/ipv6/conf/all/disable_ipv6If this returns 1, and you used option 1 above, then IPv6 was disabled. If it returns 0, then you need to update sysctl by running the below.
sudo sysctl -pIf you used option 2, then this file will not exist, signifying IPv6 was not loaded in the kernel.