Red Hat Enterprise Linux enables Internet Protocol Version 6 (IPv6) by default. However, in certain situations, some users may find it desirable to disable IPv6 support or to re-enable it after it has been disabled.
Disabling IPv6 support in CentOS/RHEL 6
1. Disabling the ipv6 module itself
1. Create a file /etc/modprobe.d/ipv6.conf with the following contents:
# vi /etc/modprobe.d/ipv6.conf options ipv6 disable=1
2. Disable the ip6tables service from starting at boot by issuing the following command:
# chkconfig ip6tables off
3. Reboot the system.
# shutdown -r now
2. Disabled via the /etc/sysctl.conf
Alternatively, this can be done via sysctl settings. disaling ipv6 using sysctl will ensure ipv6 isn’t used even if the ipv6 module is loaded and can work as a short term solution (until a full reboot). Only disables (unhooks all of the calls) for the ipv6 module, but doesn’t prevent it from loading.
1. Append the following to the end of the /etc/sysctl.conf configuration file:
# IPv6 support in the kernel, set to 0 by default net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
2. Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address:
# cp -p /etc/hosts /etc/hosts.disableipv6 # sed -i 's/^[[:space:]]*::/#::/' /etc/hosts
3. Prevent the module from loading (not recommended)
Unloading the module is not recommended due to the dependency factors it has with other modules (for example: bonding), selinux denials associated with dynamically requesting the ipv6 module functionality, and services that will require the module to be loaded.
1. Modify /etc/modprobe.d/ipv6.conf with the following contents:
# vi /etc/modprobe.d/ipv6.conf install ipv6 /bin/true
2. Restart the system.
# shutdown -r now
Re-enabling IPv6 support in CentOS/RHEL 6
1. Review the files under /etc/modprobe.d/ and remove (or comment out) of the following lines if any of them is present:
options ipv6 disable=1 install ipv6 /bin/true blacklist ipv6 alias ipv6 off
2. Configure the ip6tables service to start at boot by issuing the following command:
# chkconfig ip6tables on
3. Make sure the following options to your /etc/sysctl.conf are set to default value ‘0‘
# 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
4. Make sure the following line exists in /etc/hosts and is not commented out:
# vi /etc/hosts ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
5. Edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “-“(hyphen/dash) in the third column to “v”
6. Reboot the system to activate IPv6 support.
# shutdown -r now
How to disable or enable the IPv6 protocol in CentOS/RHEL 5
How to disable or enable the IPv6 protocol in CentOS/RHEL 4