
IPv6 may be undesirable in certain situations, for systems that can run without IPv6, and only running on IPv4, the IPv6 protocol can be disabled.
RHEL and CentOS 7 disable IPv6 stack as follows
vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
If one interface should run without IPv6, e.g. ens160.
net.ipv6.conf.ens160.disable_ipv6 = 1
Save the sysctl.conf file and enable the setting.
sysctl -p
If you want to deactivate IPv6 during operation, the following command applies.
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
Alternatively you can run this command in terminal shell.
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
IPv6 is now disabled, a reboot is not necessary.
If the removal of IPv6 for running daemons is a disaster, e.g. SSH Server, the configuration can be changed.
vi /etc/ssh/sshd_config
#AddressFamily any
AddressFamily inet
#or remove hash(#)
#ListenAddress 0.0.0.0
ListenAddress 0.0.0.0
Then restart the SSH daemon.
systemctl restart sshd
Postfix may also require to customize the ipv4 loopback interface.
vi /etc/postfix/main.cf
#inet_interfaces = localhost
inet_interfaces = 127.0.0.1
With CentOS 6, the kernel module can be customized.
vi /etc/modprobe.d/ipv6.conf
options ipv6 disable=1
Disable the IPv6 stack.
chkconfig ip6tables off
Server reboots.
reboot
Checking for IPv6 addresses.
ifconfig | grep inet6
ip a | grep inet6