IPv6 is by default enabled on CentOS/RHEL 6 systems. But in case, if it was disabled for some reason, you can follow the short howto below to re-enable it. There are basically 2 ways to disable IPv6 on CentOS/RHEL 6.
- Disable IPv6 in kernel module (requires reboot)
- Disable IPv6 using sysctl settings (no reboot required)
Method 1 : Using /etc/modprobe.d/ipv6.conf (requires reboot)
1. Confirm if ipv6 is used. IPV6 is not used if no lines with inet6 shows up.
# ifconfig |grep inet6 #
2. Modify the configuration file /etc/modprobe.d/*.conf or /etc/modprobe.conf which prevents kernel from loading ipv6 module
# grep ipv6 /etc/modprobe.conf /etc/modprobe.d/*.conf /etc/modprobe.d/ipv6.conf:1:options ipv6 disable=1 ### we need to remove this line
After removing (or hashing it out) the above line, verify:
# cat /etc/modprobe.d/ipv6.conf # options ipv6 disable=1
3. Enable ip6tables service if it is needed
# chkconfig ip6tables on
4. Reboot
# shutdown -r now
5. Verify if you can now see the inet6 line in the ifconfig command output.
# ifconfig |grep inet6 inet6 addr: 2405:200:a60:fd00:250:56ff:fe96:f0e/64 Scope:Global inet6 addr: fe80::250:56ff:fe96:f0e/64 Scope:Link inet6 addr: ::1/128 Scope:Host
Method 2 : Using /etc/sysctl.conf (online)
1. Append below line to the file /etc/sysctl.conf.
# vi /etc/sysctl.conf # IPv6 support in the kernel, set to 0 by default net.ipv6.conf.all.disable_ipv6 = 0 net.ipv6.conf.default.disable_ipv6 = 0
2. To apply the changes for the current sysctl parameters, execute :
# sysctl -p
3. Use, ‘sysctl -a’ to verify the parameter values.
# sysctl -a | grep net.ipv6.conf net.ipv6.conf.all.disable_ipv6 = 0 net.ipv6.conf.default.disable_ipv6 = 0
CentOS / RHEL 6 : How to disable IPv6
CentOS / RHEL 7 : How to disable IPv6