How to Completely Disable the IPv6 Protocol in Ubuntu Linux

Internet Protocol version 6 (IPv6) is the modern standard for network routing, designed to replace the older IPv4 system which has essentially run out of unique addresses. While IPv6 is the future of the internet, many local home networks, older enterprise VPNs, and legacy applications are not yet fully configured to handle it correctly. If your Ubuntu system is trying to connect via an unstable IPv6 connection while your router only properly supports IPv4, you may experience random disconnects, excruciatingly slow DNS resolution, or complete network failure.

If you are troubleshooting a stubborn network issue on your Ubuntu machine, temporarily (or permanently) disabling the IPv6 protocol forces your system to rely entirely on the much older, universally supported IPv4 standard. You can achieve this by modifying the core kernel parameters via the terminal.

Disabling IPv6 Temporarily via Sysctl

If you only want to test if IPv6 is the cause of your network issues, you can disable it temporarily. This method changes the kernel settings in real-time, but the changes will be completely erased the next time you reboot your computer.

  1. Open your terminal window (press Ctrl + Alt + T).
  2. To disable IPv6 for all network interfaces simultaneously, type the following command and press Enter:
    sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
  3. You must also run a second command to ensure the default interface is caught:
    sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
  4. Finally, apply the rule to the loopback interface:
    sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

To verify that IPv6 is now turned off, type ip a and press Enter. Look at your network adapter in the output list; you should see an inet line (which is your IPv4 address) but the inet6 line should be completely missing.

Disabling IPv6 Permanently via GRUB

If disabling the protocol fixed your network issues and you want to ensure it remains turned off even after you restart your machine, the most reliable method is to instruct the bootloader (GRUB) to ignore IPv6 before the operating system even finishes loading.

  1. Open your terminal.
  2. You need to edit the main GRUB configuration file. Use the nano text editor by typing:
    sudo nano /etc/default/grub
  3. Use your arrow keys to scroll down the file until you find the line that begins with GRUB_CMDLINE_LINUX_DEFAULT= or GRUB_CMDLINE_LINUX=.
  4. You need to add the command ipv6.disable=1 inside the quotation marks on that line. For example, if the line currently looks like this:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    Change it to look exactly like this:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
  5. Press Ctrl + O (the letter O, not zero) to write the changes, then press Enter to confirm the filename.
  6. Press Ctrl + X to exit the nano editor.
  7. Finally, you must command the system to regenerate the boot files with your new setting. Type the following command and press Enter:
    sudo update-grub

Restart your computer. When Ubuntu boots up, the IPv6 protocol will be completely disabled at the kernel level.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.