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
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
Now, to disable IPv6 use the following command.
# sysctl --load /etc/sysctl.d/70-ipv6.conf
IPv6 should now be disabled.
To verify if IPv6 is disabled, run the following ip command.
# ip a | grep inet6
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.
I think it would be more correct
sysctl --system
, not sysctl –load /etc/sysctl.d/70-ipv6.conf.nmcli connection modify interface ipv6.method ignore
Error: unknown connection ‘interface’.
CentOS Linux release 8.4.2105
Replace {interface} with your actual network adapter used by the system.
For example, in my case, its ens33.