Categories: Ubuntu

Ubuntu 22.04 Disable IPv6

IPv6 is the advanced version of IPv4 and was introduced to ensure we do not run out of IP addresses. However, for a small network, you do not require IPv6. Besides, your ISP probably does not support IPv6. And when you have an application that supports IPv6, you will run into an error when trying to install it.

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

Sponsored

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.

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

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.all.disable_ipv6=1

$ 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.

$ sudo apt update

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.

Sponsored

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.

$ sudo update-grub

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.

Conclusion

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.

Ubuntu Server Admin

Recent Posts

How to Install nvidia-smi on Ubuntu or Debian Linux

In this article, we will see how to install nvidia-smi on Ubuntu or Debian Linux.…

7 hours ago

How to Install clang tool on Ubuntu or Debian Linux

In this article, we will see how to install clang tool on Ubuntu or Debian…

1 day ago

How to resolve Ubuntu 20.04 Container Signature Errors on Raspberry Pi ARM Devices

When working with Docker containers on Raspberry Pi devices, you might encounter frustrating signature verification…

2 days ago

How to fix DNS Resolution Issues with OpenVPN on Ubuntu 18.04

You’ve recently upgraded to Ubuntu 18.04 and found that your OpenVPN connection no longer resolves…

2 days ago

How to Fix Ubuntu 18.04 System Monitor Launch Issues

Have you ever tried to open System Monitor on your Ubuntu 18.04 system only to…

3 days ago

What is System Hardening? Essential Checklists from OS to Applications

System hardening means locking down a system and reducing its attack surface: removing unnecessary software…

3 days ago