How to Disable IPv6 in CentOS

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.

Disabling IPv6 in CentOS

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