We have already seen how to disable ipv6 globally on CentOS / RHEL 7. There could be an ask to disable ipv6 just for a particular interface on the system and not for all the available interfaces or system-wide. The posts describe steps to disable ipv6 on a particular interface in CentOS / RHEL 7.
Note: Adding IPV6INIT=no in the specific interface configuration files is not helpful and it does not disable ipv6 on that interface.
Disabling ipv6 on a particular interface only
1. Below ipv6 parameter can be used on a per-interface basis to enable or disable ipv6.
net.ipv6.conf.[interface].disable_ipv6 = [value]
interface – name of the interface where ipv6 needs to be disabled. For example eth1
value – 0 (enable) or 1 (disable) ipv6 on the interface.
2. So to disable ipv6 just on the eth1 interface, you can add below parameter in /etc/sysctl.conf file to make permanent changes.
# vi /etc/sysctl.conf net.ipv6.conf.eth0.disable_ipv6 = 1
3. Run below command to apply the changes immediately;
# sysctl -p
It is not helpful to add IPV6INIT=no parameter to interfaces that need to disable IPv6. Link-local ipv6 can still be seen on that interface. Changing the sysctl parameter for the specific interface can disable the ipv6 on that particular interface only and not globally on the system.