查看系统IPv6的启用状态
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
cat /proc/sys/net/ipv6/conf/default/disable_ipv6
临时禁用IPv6
echo 1 >/proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 >/proc/sys/net/ipv6/conf/default/disable_ipv6
# 或着
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
永久禁用IPv6
echo " ">>/etc/sysctl.conf
echo "# made for disabled IPv6 in $(date +%F)">>/etc/sysctl.conf
echo 'net.ipv6.conf.all.disable_ipv6 = 1'>>/etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1'>>/etc/sysctl.conf
echo 'net.ipv6.conf.lo.disable_ipv6 = 1'>>/etc/sysctl.conf
tail -5 /etc/sysctl.conf
sysctl -p
netstat -anptl
临时启用IPv6
echo 0 >/proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 >/proc/sys/net/ipv6/conf/default/disable_ipv6
# 或着
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0
永久启用IPv6
vim /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
sysctl -p