ubuntu disable ipv6

After over 2 decades of being in the adoption phase, IPv6 is in a unique stage at the moment.

On one hand, there are cases where disabling IPv6 is necessary. For instance, some VPNs only encrypt IPv4 traffic. This means if you don’t disable IPv6, it would defeat the purpose of using the VPN.

On the other hand, because we’re pretty far along with the IPv6 transition, many services required IPv6 to work properly. For instance, you may encounter problems with X11 Forwarding if IPv6 is disabled.

Basically, IPv6 may or may not be necessary depending on your exact setup and goals. If you do decide to disable IPv6, this article will be helpful.

Disable IPv6 from Network Settings

The NetworkManager GUI lets you configure various settings including an interface’s IPv6 address.

  1. Launch the Settings app and switch to the Network (wired) or WiFi tab.
    network settings ubuntu
  2. Click on the Settings cog and switch to the IPv6 tab. Select Disable and click on Apply.
    disable ipv6 on ubuntu
  3. Reset the connection (toggle on/off) to apply the changes.
    disable connection ubuntu
  4. Check the connection settings again to verify that it was disabled.
    disable ipv6 ubuntu

Temporarily Disable IPv6 (Sysctl)

You can modify the ipv6 configurations with sysctl if you only need to disable it for the current session. IPv6 will be re-enabled after you restart your machine.

First, verify that IPv6 is currently enabled with  

ip a

Execute the following commands to disable IPv6.

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

This time, verify that IPv6 was disabled with

ip a

Permanently Disable IPv6 (Sysctl)

Sysctl is handy as you can modify kernel parameters at runtime with it, but the change isn’t persistent. If you want to permanently disable IPv6, you can directly edit the sysctl.conf file.

Open the config file with a text editor like Nano.

sudo nano /etc/sysctl.conf

Add these lines to the file and save the changes.

#disable ipv6
ipv6.conf.all.disable_ipv6 = 1
ipv6.conf.default.disable_ipv6 = 1
ipv6.conf.lo.disable_ipv6 = 1

Afterward, load the new settings and verify the change with

sysctl -p
ip a

Disable IPv6 with GRUB

Sometimes, the system doesn’t load certain parameters (such as the IPv6 parameters we set earlier) at boot. This can cause the ‘persistent’ change to revert after rebooting. In such cases, you can disable IPv6 by editing the GRUB config instead.

Open the config file with a text editor like Nano.

sudo nano /etc/default/grub

Add ipv6.disable=1 to the GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX lines and write out the changes.

Update GRUB to apply the changes.

sudo update-grub

Finally, restart your PC and verify that IPv6 is disabled.

shutdown -r now
ip a
Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.