Disabling IPv6
Internet Protocol version 6 (IPv6) is the addressing scheme used by network interfaces on an IPv6 network. If you don’t want to use IPv6, you can disable it temporarily or permanently. In this article you’ll learn two ways to disable IPv6 on a CentOS 8 Linux machine.
First, check whether IPv6 is enabled on your CentOS 8 machine with the ip command:
ip a | grep inet6
If IPv6 is enabled, you’ll see some inet6 lines. If the command prints nothing, IPv6 is already disabled on all your network interfaces.
Disable IPv6 with sysctl
This method disables IPv6 without a reboot. However, as you’ll see, it takes a bit more work than the permanent method.
First, create a new sysctl configuration file, /etc/sysctl.d/70-ipv6.conf:
vi /etc/sysctl.d/70-ipv6.conf
Add the following lines and save the file:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Now apply it to disable IPv6:
sysctl --load /etc/sysctl.d/70-ipv6.conf
IPv6 should now be disabled. To check, run the ip command again:
ip a | grep inet6
If it prints nothing, IPv6 is disabled on all your network interfaces.
With this method, some network interfaces may still use IPv6 after a reboot. That’s because CentOS 8 uses NetworkManager by default.
To stop an interface from using IPv6 completely, use nmcli:
nmcli connection modify interface ipv6.method ignore
Finally, reboot your CentOS 8 machine:
reboot
Disable IPv6 with a kernel boot option
This method needs a reboot after configuration, but it’s the best way to disable IPv6.
Open the default GRUB configuration, /etc/default/grub, in vi:
vi /etc/default/grub
Go to the end of the file, press O to open a new line and add:
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"
Save the file and exit.
Next, update the GRUB CFG files. To find them, run:
ls -lh /etc/grub*.cfg
You’ll see two GRUB CFG paths: /boot/grub2/grub.cfg and /boot/efi/EFI/centos/grub.cfg.
Generate a new GRUB configuration and save it to /boot/grub2/grub.cfg:
grub2-mkconfig -o /boot/grub2/grub.cfg
Then generate it again for /boot/efi/EFI/centos/grub.cfg:
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Finally, reboot your CentOS 8 machine:
reboot
After the reboot, check whether IPv6 is disabled:
ip a | grep inet6
If the command prints nothing, IPv6 is disabled.
Conclusion
You’ve learned two ways to disable IPv6 on CentOS 8 Linux: with sysctl and with a kernel boot option. Disabling IPv6 with sysctl is temporary, while the kernel boot option is permanent and the better method.
We hope you found this article useful. Follow Mizbandade for more.

