How to Disable IPv6 on Ubuntu 20.04 and 22.04 LTSIPv6, the latest version of the Internet Protocol, is designed to replace IPv4 and provide a larger address space.

I used IPv6 when setting up email servers for compliance and deliverability.

However, there might be situations where you need to disable IPv6 on your Ubuntu 20.04 or 22.04 LTS system. This guide will walk you through three methods to disable IPv6 effectively.

How to Disable IPv6 on Ubuntu 20.04 and 22.04 LTS

Method 1. Editing the sysctl.conf File

Disable IPv6 sysctl.conf File

Open your favorite SSH client. Run the terminal.

Use a text editor, such as Nano or Vim, to open the sysctl.conf file:

nano /etc/sysctl.conf

Add the following lines at the end of the file:

# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Do not set the values to zero as it will enable the IPv6.

Note: Some VPS might have additional lines for disabling IPv6.

Save and exit the editor.

Apply the changes by running:

sudo sysctl -p

Or reboot your server (This works best for me.):

sudo reboot

Test by running the following command:


You should not be able to connect to Google. You can also use this test for the remaining methods.

Method 2. Using GRUB Configuration

Disable IPv6 GRUB UbuntuOpen the GRUB configuration file in a text editor:

nano /etc/default/grub

Find the line starting with GRUB_CMDLINE_LINUX and add ipv6.disable=1 at the end of the quotes:


Save and exit the editor.

Update GRUB:

sudo update-grub

Reboot your system to apply the changes:

sudo reboot

Method 3. Blacklisting the IPv6 Kernel Module

Disable IPv6 Kernel Module

Open the sysctl.conf file:

sudo nano /etc/modprobe.d/blacklist.conf

Add the following lines:

# Disable IPv6
blacklist ipv6

Save and exit the editor.

Reboot your system for the changes to take effect:

sudo reboot

Why disable IPv6?

Compatibility Issues

Some legacy applications, network equipment, or operating systems may not fully support IPv6. In such cases, disabling IPv6 can prevent compatibility issues and ensure that services and applications work seamlessly on IPv4-only networks.

Network Configuration Complexity

Managing both IPv4 and IPv6 configurations simultaneously can increase network complexity. In environments where IPv6 is not essential and doesn’t provide significant benefits, simplifying the network by disabling IPv6 might be a preference.

Security Concerns

While IPv6 incorporates security features such as IPsec, there may be specific security concerns or vulnerabilities associated with IPv6 that are not present in IPv4. In certain scenarios, organizations might choose to disable IPv6 to mitigate potential risks or as a precautionary measure until security concerns are adequately addressed.

Performance Issues

In some cases, there may be perceived or actual performance issues related to IPv6, such as longer routing tables or inefficient routing. Disabling IPv6 can be a temporary solution while investigating and addressing performance concerns.

Internet Connection Stability

Some users or organizations might experience issues with internet connectivity or speed due to misconfigurations or conflicts involving IPv6. Disabling IPv6 can be a troubleshooting step to identify and resolve such problems.

Preference for IPv4

In certain environments, administrators or users may have a strong preference for IPv4 and may not see an immediate need to adopt IPv6. Disabling IPv6 allows them to continue using IPv4 exclusively.

Testing and Isolation

In specific testing or isolated environments, administrators may prefer to work exclusively with IPv4 for simplicity. Disabling IPv6 in such scenarios helps create a controlled testing environment without the presence of IPv6-related variables.


Disabling IPv6 on Ubuntu 20.04 and 22.04 LTS can be necessary in certain situations, and the methods outlined above offer different approaches to achieve this.

Choose the method that best fits your requirements and ensure that you reboot your system to apply the changes successfully. Method 1 works best for me.

Keep in mind that disabling IPv6 might have implications for certain network functionalities, so use these methods judiciously based on your specific needs.

Leave a Reply

Your email address will not be published. Required fields are marked *