How to Disable IPv6 in CentOS 8

An internet protocol version 6 (IPv6) is an identifier of a network interface that’s involved in an IPv6 computer network. If you don’t want to use Ipv6 addressing, you can opt to disable it either temporarily or permanently.

In this article, you are going to learn a few ways to disable IPv6 in your CentOS 8 Linux machine.

Disabling IPv6 in CentOS 8

First, check whether IPv6 is enabled on your CentOS 8 machine using the following ip command.

# ip a | grep inet6
Check IPv6 Status in CentOS 8
Check IPv6 Status in CentOS 8

If IPv6 enabled, you can see some inet6 lines, however, if the command doesn’t print anything, IPv6 is disabled on all your network interfaces.

Disable IPv6 Using sysctl Command

This method is for temporary disabling IPv6. You don’t require to reboot your system for the changes to take place. However, it’s quite complicated than the permanent method you will learn shortly.

First create a new sysctl configuration file /etc/sysctl.d/70-ipv6.conf using the following command.

# vi /etc/sysctl.d/70-ipv6.conf

Next, add the following lines and save the file.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Sysctl Configuration File
Sysctl Configuration File

Now, to disable IPv6 use the following command.

# sysctl --load /etc/sysctl.d/70-ipv6.conf
Temporarily Disable IPv6 in CentOS 8
Temporarily Disable IPv6 in CentOS 8

IPv6 should now be disabled.

To verify if IPv6 is disabled, run the following ip command.

# ip a | grep inet6
Check IPv6 Disabled in CentOS 8
Check IPv6 Disabled in CentOS 8

If the command doesn’t return anything implying that IPv6 has been disabled on all your network interfaces.

When using this method, some of your network interfaces may still use IPv6 once you reboot your system. This happens because CentOS 8 uses Network Manager by default.

To completely stop using IPv6, use the following nmcli command.

# nmcli connection modify interface ipv6.method ignore

Finally, reboot your CentOS 8 machine.

# reboot

Disable IPv6 Using The Kernel Boot Option

The kernel boot option requires a system reboot after the configuration. It’s the best method of disabling IPv6.

To use this method, open the default GRUB configuration file /etc/default/grub with the vi text editor, as shown below.

# vi /etc/default/grub

Next, head to the end of the file and press O to create a new line and type the following.

GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"

Next, save and exit the configuration file.

The next step is to update the GRUB CFG files. Type the following command to locate the grub files.

#  ls -lh /etc/grub*.cfg

You will see 2 GRUB CFG file paths: /boot/grub2/grub.cfg and /boot/efi/EFI/centos/grub.cfg.

Type the following command to create a new GRUB configuration file and save it to /boot/grub2/grub.cfg.

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

Next, type the following command to create a new GRUB configuration file and save it to /boot/efi/EFI/centos/grub.cfg.

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

Finally, reboot your CentOS 8 machine.

# reboot

After rebooting, type the following command to verify whether IPv6 is disabled.

# ip a | grep inet6

If the command does not print anything, it means IPv6 is disabled.

Summary

In this article, you have learned about two ways you can disable IPv6 on your CentOS 8 Linux machine. The first method is by using sysctl while the second is by using the Kernel boot option. While Disabling IPv6 Using sysctl is temporary, the Kernel boot option is permanent and is the best method.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

3 Comments

Leave a Reply
  1. nmcli connection modify interface ipv6.method ignore
    Error: unknown connection ‘interface’.

    CentOS Linux release 8.4.2105

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.