IPv6 is the future but you do not need it right now. You can decide to disable it permanently or temporarily, depending on your goal. On Ubuntu 22.04, we will cover the steps you should follow to disable IPv6.
How to Disable IPv6 on Ubuntu 22.04
You must have root privileges to disable IPv6. Many applications run seamlessly with IPv4. Since IPv6 is enabled by default on Ubuntu 22.04, it makes sense to disable it temporarily or permanently. This way, you will face errors when installing any applications that support IPv6, yet your ISP does not support it.
First, let us check the status of IPv6 on our Ubuntu 22.04. For that, use the cat command to display a Boolean output of whether IPv6 is disabled by running the command below.
We get our output as 0, meaning IPv6 is enabled by default. Let us proceed to see the two ways you can use to disable it.
1. Ubuntu 22.04 Disable IPv6 Temporarily
The systemd lets you disable IPv6 temporarily such that your changes will persist, provided you do not reboot the system. This option is handy when you want to install an application that supports IPv6 but wants to install it via IPv4.
You must change the IPv6 configuration files and disable Ipv6 by changing its value to 1. This way, your changes will last for the short time that your system is online. Once you reboot, IPv6 will be enabled by default.
Run the three commands below with sudo privileges.
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
Once you execute, you will get the Boolean value this time as 1 to imply that the IPv6 is now disabled.
To revert the changes, simply reboot your system. Suppose you want to persist the changes and have the IPv6 disabled at boot time, check out the next method below.
2. Ubuntu 22.04 Disable IPv6 Permanently
If you are sure you do not need to have IPv6 enabled on your Ubuntu 22.04, there is an option for permanently disabling it. Here, we will make the changes on the /etc/default/grub and not via the ystem.
Open the /etc/default/grub using an editor of choice. Our target is the GRUB_CMDLINE_LINUX*
Change the value of the two lines to append the “ipv6.disable=1” You will find that some already have the boor parameters configured to “quiet splash.” For such a case, append on the same line. If no boot parameters are set, set the ipv6.disable=1 to ensure the new parameters appear like in the example below.
Save and exit the file. Once you have updated the boot parameters to disable the IPv6, you must update the GRUB. This way, your changes will be saved and persist even after boot up.
Run the update command below.
Lastly, reboot your Ubuntu for the changes to apply. If you check the status of the IPv6 on your system after the reboot, it displays the output as 1 to confirm we’ve disabled it.
Your IPv6 on Ubuntu 22.04 is now disabled permanently. If you get a change of mind later, open the /etc/default/grub file, remove the disable command, update the GRUB, and reboot your system.
IPv6 is enabled by default on Ubuntu 22.04. However, you can temporarily or permanently disable it. This post has discussed steps to disable IPv6 on Ubuntu 22.04.