Tuesday, October 07, 2014

Disable IPv6 on CentOS




Method #1 (recommended)

Permanent: Edit /etc/sysctl.conf to:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Runtime only:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

Method #2 (discouraged: it may interfere with SELinux and other components)

Add the following to /etc/sysconfig/network-scripts/ for the device
IPV6INIT=no

SCRIPT (caution!):

echo -e "net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1" | while read f; do if [ $(grep -c "$f" /etc/sysctl.conf) -eq 0 ]; then echo -e "\n$f" >> /etc/sysctl.conf; fi; done

No comments: