How to disable IPv6 address on Ubuntu 22.04 LTS Jammy Jellyfish

IPv6, Internet Protocol version 6 is the most recent version of the Internet Protocol (IP). It is a communications protocol which is used for identification and location for computers on networks. Its purpose it to route traffic across the Internet. This tutorial will show you how to temporarily or permanently disable IPv6 on Ubuntu 22.04 LTS Jammy Jellyfish.

In this tutorial you will learn:

  • How to temporarily disable IPv6
  • How to permanently disable IPv6
Disable IPv6 address on Ubuntu 22.04 LTS Jammy Jellyfish
Disable IPv6 address on Ubuntu 22.04 LTS Jammy Jellyfish
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Disabling IPv6 address on Ubuntu 22.04 LTS Jammy Jellyfish step by step instructions




IPv6 networking can be disabled through systemd, but the change will not be permanent. To permanently disable IPv6 on Ubuntu 22.04, we will need to edit the kernel boot parameters.

Temporarily disable IPv6

To temporarily disable IPv6 address on Ubuntu 22.04 Jammy Jellyfish execute the following commands:

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

The above commands will temporarily disable IPv6, meaning that the settings will not persist after reboot. To re-enable IPv6 reboot your system or execute the above commands again however reverse the logic and change 1 to 0. In case you need more permanent solution to disable IPv6 even after system reboot follow the steps below:

Permanently disable IPv6

  1. Start by opening a command line terminal and using nano or your favorite text editor to open the following GRUB configuration file with root permissions.
    $ sudo nano /etc/default/grub
    
  2. Next, change the following line. If your line already has some boot parameters configured such as splash or quiet, just append your change after them.
    FROM:
    GRUB_CMDLINE_LINUX_DEFAULT=""
    TO:
    GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
    
  3. After you have made that change to the file, save the changes and exit. Then, execute the following command to update GRUB.
    $ sudo update-grub
    

In case you need to re-enable the IPv6 network addresses simply remove the ipv6.disable=1 from the /etc/default/grub file and run the update-grub command.



Closing Thoughts

In this tutorial, you saw how to disable IPv6 networking on Ubuntu 22.04 Jammy Jellyfish Linux. This included a temporary solution with systemd and a permanent solution by editing the kernel boot parameters. You should no longer be able to use IPv6 addresses once these changes have been made, so your system will be stuck with only IPv4.