Keeping IPv6 enabled means you have to configure your firewall for IPv4 as well as IPv6. If you fail to do so, then your open IPv6 ports will be a security risk for you. So, that's a lot of extra work and extra threats unless you're using IPv6.
So, you might be thinking, if I am not using IPv6, why am I keeping it enabled? Well, you don't have to. On Ubuntu, you can disable IPv6 very easily.
In this article, I am going to show you how to disable IPv6 on Ubuntu. So, let's get started.
Disabling IPv6:
The easiest and most effective way to disable IPv6 is to disable it on system boot using kernel boot parameters. If you pass ipv6.disable=1 boot parameter when you boot into Ubuntu, IPv6 will be disabled completely.
We are not manually doing that every time we start our computer of course. So, you have to put ipv6.disable=1 as a default boot parameter.
To do that, first, edit the /etc/default/grub configuration file with the following command:
$ sudo nano /etc/default/grub
The configuration file should be opened. There are two lines that you have to edit, GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX as marked in the screenshot below.
Now, add ipv6.disable=1 in GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX as shown in the screenshot below. Once you're done, save the file by pressing
Now update the GRUB bootloader configuration files for the changes to take effect with the following command:
$ sudo update-grub2
GRUB bootloader configuration files should be updated.
Before you restart your computer, I just want to show you that IPv6 is enabled for now.
To check whether IPv6 is enabled, you can run the following command:
$ test -f /proc/net/if_inet6 && echo "IPv6 is enabled."|| echo "IPv6 is disabled."
As you can see, IPv6 is enabled at the moment.
Now, restart your computer with the following command:
$ sudo reboot
Once your computer boots, IPv6 should be disabled as you can see in the screenshot below.
$ test -f /proc/net/if_inet6 && echo "IPv6 is enabled."|| echo "IPv6 is disabled."
So, that's how you disable IPv6 on Ubuntu. Thanks for reading this article.