Description
This 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.
Prerequisites
Configuration
To 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 1
Open /etc/sysctl.conf using a text editor.
sudo nano /etc/sysctl.conf
Then 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 2
Open /etc/default/grub (default config file for grub).
sudo nano /etc/default/grub
Then 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.
sudo update-grub
Testing
To verify that IPv6 was disabled, we can check the contents of the following.
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
If 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 -p
If you used option 2, then this file will not exist, signifying IPv6 was not loaded in the kernel.
No comments:
Post a Comment