How to Disable IPv6 on Ubuntu

Publish date: 2024-07-12

While IPv6 is essential for the long-term growth of the internet, there are situations where you might need to disable it on your Ubuntu system.

Here's how to disable IPv6 on Ubuntu to help you address compatibility issues, network configuration, or specific use cases that require IPv6 deactivation.

How to Disable IPv6 Permanently on Ubuntu

By default, IPv6 is enabled and is used in parallel with IPv4.

To disable IPv6 on your Ubuntu system, open the terminal by pressing Ctrl + Alt + T and use the nano editor to open the sysctl configuration file:

sudo nano /etc/sysctl.conf 

Now, add the following code in the configuration file for disabling the IPv6 services:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

In the above code:

After adding the given code, press Ctrl + O to save changes and exit the editor. Now, apply changes to the system with:

sudo sysctl -p 

Restart your network services with:

sudo systemctl restart systemd-networkd 

Verify the status of disabled IPv6 services by running:

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

If the output displays "1" as the status, it means that IPv6 has been successfully disabled on Ubuntu.

How to Temporarily Disable IPv6 on Ubuntu

To temporarily disable IPv6 on Ubuntu, run the following systemctl command with the -w option:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 

Now, restart the network services with:

sudo systemctl restart systemd-networkd 

As a result, all dependencies will be configured to temporarily disable the IPv6 services.

Take Charge of Your Ubuntu PC's Network Configurations

Ubuntu makes it relatively straightforward to control IPv6 settings, ensuring that you can configure your system's network behavior to your specific needs. Remember to use this knowledge carefully, as IPv6 will continue to play a crucial role in the global internet infrastructure.

ncG1vNJzZmivp6x7rq3KnqysnZ%2Bbe6S7zGiboquRl7mmeciprW9ln6N6tq7Up6uuZw%3D%3D