How to Disable IPv6 on Ubuntu

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

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

How to permanently disable IPv6 on Ubuntu

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

To disable IPv6 on your Ubuntu system, open a 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 to the configuration file to disable 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 code above:

  1. The first line disables IPv6 for all network interfaces on the system
  2. The second line specifically targets the default interface and disables it
  3. The third line disables IPv6 on the loopback interface, meaning the machine will not use IPV6 for internal communication.

How to Disable IPv6 on Ubuntu Picture 1How to Disable IPv6 on Ubuntu Picture 1

 

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

How to Disable IPv6 on Ubuntu Picture 2How to Disable IPv6 on Ubuntu Picture 2

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

How to Disable IPv6 on Ubuntu Picture 3How to Disable IPv6 on Ubuntu Picture 3

If the output shows a status of "1" , it means 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

How to Disable IPv6 on Ubuntu Picture 4How to Disable IPv6 on Ubuntu Picture 4

Now, restart network services with:

sudo systemctl restart systemd-networkd

Therefore, all dependencies will be configured to temporarily disable IPv6 services.

Ubuntu makes controlling IPv6 settings relatively simple, ensuring that you can configure your system's networking behavior to your specific needs. Remember to use this knowledge carefully as IPv6 will continue to play an important role in the global Internet infrastructure.

3.5 ★ | 2 Vote