Disabling IPv6 completely can be useful in LAN or Lab environments, or maybe you just decided to not use IPv6 for now. I will show you how to disable IPv6 using kernel boot parameters.
Edit your /etc/default/grub configuration file with your favorite editor:
sudo vi /etc/default/grub
Your configuration should look similar to the following one:
GRUB_DEFAULT=0 GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=0 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX=""
Set the option ipv6.disable=1 in GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX. Both lines should then look like the following:
If there are already other options set you need to add new ones separated by a space:
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity ipv6.disable=1" GRUB_CMDLINE_LINUX="ipv6.disable=1"
For our changes to take effect you have to update the GRUB bootloader:
After the configuration files are updates without an error reboot your system:
sudo reboot now
Once your system is up again check the IP configuration. There should be no IPv6 addresses:
Quick extra note: If you are using a hypervisor like ESXi you may need to shut down your VM and boot it again for the IP changes to take effect in your GUI.
Using kernel boot parameters is the easiest way to disable IPv6. To enable it again remove the ipv6.disable=1 parameter and reboot your server.