Centos7关闭ipv6方法
1、使用ifconfig命令查看,如果出现ipv6表明开启了

2、cat /etc/sysctl.conf|grep -q "net.ipv6.conf.all.disable_ipv6=1"if [ "$?" != "0" ]; thencat >> /etc/sysctl.conf << EOFnet.ipv6.conf.all.disable_ipv6=1EOFfi

3、使用vim /etc/sysctl.conf进行验证

4、cat /etc/sysconfig/network|grep -q "NETWORKING_IPV6=no"if [ "$?" != "0" ]; thencat >> /etc/sysconfig/network << EOFNETWORKING_IPV6=noEOFfi

5、使用vim /etc/sysconfig/network进行验证

6、cat /etc/sysconfig/network-scripts/ifcfg-eth0|grep -q "IPV6INIT=no"if [ "$?" != "0" ]; thencat >> /etc/sysconfig/network-scripts/ifcfg-eth0 << EOFIPV6INIT=noEOFfi

7、使用vim /etc/sysconfig/network-scripts/ifcfg-eth0进行验证

8、关闭ip6tables开机自启动chkconfig ip6tables off

9、sysctl -p

10、使用ifconfig再次进行验证
