Computer >> Computer tutorials >  >> System >> Linux

Disable IPv6 on Ubuntu: Step‑by‑Step Guide

Disable IPv6 on Ubuntu: Step‑by‑Step Guide

Disable IPv6 on Ubuntu: Step‑by‑Step Guide

Published Oct 16, 2023, 4:45 PM EDT

Sharqa is a technical content writer who specializes in creating high-quality, valuable, and SEO-optimized content. She has delivered content related to different operating systems, programming languages, GUI-based apps, IT, and Technology.

Sign in to your MakeUseOf account

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:

  • The first line disables IPv6 for all network interfaces on the system
  • The second line specifically targets the default interface and disables it
  • The third line disables the IPv6 on the loopback interface, which means the machine won't use IPV6 for internal communication
Disable IPv6 on Ubuntu: Step‑by‑Step Guide

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
Disable IPv6 on Ubuntu: Step‑by‑Step Guide

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
Disable IPv6 on Ubuntu: Step‑by‑Step Guide

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
Disable IPv6 on Ubuntu: Step‑by‑Step Guide

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.