How to Disable IPv6 in RHEL, Rocky & AlmaLinux

Brief: This guide explores how to disable IPv6 on RHEL, Rocky Linux, and AlmaLinux distributions.

In computing, there are two types of IP addressing; IPv4 and IPv6.

IPv4 is a 32-bit address that contains 4 octets segmented by three periods. It is the most widely used IP addressing scheme and supports up to 232 IP addresses. There is a good chance that your device is using IPv4 addressing to connect to any network – wired or wireless.

On the other hand, IPv6 is a 128-bit address with 16 octets. It’s a lot longer than IPv4 and provides 2128 IP addresses. This amounts to 340 undecillion IP addresses, while IPv4 is limited to 4.3 billion IP addresses.

In most cases, IPv4 and IPv6 work hand in hand without any problem. However, there are times you might need to temporarily disable IPv6 addressing, for example, when troubleshooting network faults.

In this guide, we will demonstrate how to disable IPv6 on RHEL, Rocky, and AlmaLinux distributions.

Permanently Disable IPv6 on RHEL, Rocky & AlmaLinux

In this section, we will walk you through how to permanently disable IPv6. Before anything else, confirm that your Linux system is using IPv6 using the following ip command as follows:

$ ip a | grep inet6

From the output below, you can see that IPv6 is enabled. The next step is to disable IPv6.

Check IPv6 Support in Linux
Check IPv6 Support in Linux

We are going to disable IPv6 by making changes to the grub configuration file.

So, access the GRUB settings file as shown.

$ sudo vim /etc/default/grub

Add the line below at the very end.

GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"
Disable IPv6 in Grub Configuration
Disable IPv6 in Grub Configuration

Save the changes and exit.

For the change to be applied, we need to generate a new GRUB configuration file. To do so, run the command:

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Generate GRUB Configuration
Generate GRUB Configuration

In addition, generate an EFI GRUB configuration file for EFI systems as shown.

$ sudo grub2-mkconfig -o /boot/efi/EFI/rocky/grub2.cfg

Thereafter, reboot your system

$ sudo reboot

and, once again, check if IPv6 is supported.

$ ip a | grep inet6

If you get no output that means IPv6 is now disabled.

Temporarily Disable IPv6 on RHEL, Rocky & AlmaLinux

The other option is to disable IPv6 temporarily, which can be achieved by editing the /etc/sysctl.conf file or adding a configuration file in the /etc/sysctl.d directory.

You can make changes to the /etc/sysctl.conf file using the following command:

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

Then verify that IPv6 is disabled.

$ ip a | grep inet6

Alternatively, you can manually edit the /etc/sysctl.conf file.

$ sudo vim /etc/sysctl.conf

Append the following lines to disable IPv6 for all network adapters.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Save the changes and exit. Then run the following command to apply the changes.

$ sudo sysctl -p

Re-enabling IPv6 on RHEL, Rocky & AlmaLinux

Open /etc/default/grub file and remove the entry ipv6.disable=1 from the GRUB_CMDLINE_LINUX as shown.

GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX"

Run the grub2-mkconfig command to regenerate the grub.cfg file:

# grub2-mkconfig -o /boot/grub2/grub.cfg

Alternatively, on UEFI systems, run the following:

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Make sure to replace redhat with your distribution name rocky or almalinux.

Reboot the system to disable IPv6 support.

If you’ve temporarily enabled IPv6, just remove the following lines from /etc/sysctl.conf file and reboot the system.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Conclusion

Unless required, it is generally not recommended to disable IPv6 on your Linux system as it might lead to issues, especially when using a DHCP server that still supports IPv6.

In this tutorial, We have covered various ways in which you can disable IPv6 on RHEL, Rocky, and AlmaLinux. Your feedback on this guide is highly welcome.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “How to Disable IPv6 in RHEL, Rocky & AlmaLinux”

  1. Hi

    Nice tutorial, tried it on my centos.

    It works, however, there are a few inconsistencies I noticed.

    -w key doesn’t necessarily write changes to /etc/sysctl.conf, in my case it didn’t.

    Then, if I append some lines to /etc/sysctl.conf through vim and reboot the system, these changes are still applied. This means, the method with manual editing configs in /etc/sysctl.conf isn’t temporary, but rather permanent change.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.