Loading... Debian开启和关闭Ipv6的方法 检查系统是否有加载ipv6内核 `lsmod | grep ipv6` 返回类似下面的数据,则表示加载了ipv6内核 ``` nf_reject_ipv6 16384 1 ip6t_REJECT nf_log_ipv6 16384 5 nf_conntrack_ipv6 20480 8 nf_defrag_ipv6 16384 1 nf_conntrack_ipv6 nf_log_common 16384 2 nf_log_ipv6,nf_log_ipv4 nf_conntrack 114688 8 nf_conntrack_ipv6,nf_conntrack_ftp,nf_conntrack_ipv4,nf_conntrack_broadcast,nf_nat_ftp,nf_conntrack_netbios_ns,xt_conntrack,nf_nat ``` 检查是否有ipv6地址 ``` ifconfig ip address list netstat -anptl ``` 临时关闭ipv6的命令 ``` sysctl -w net.ipv6.conf.all.disable_ipv6=1 sysctl -w net.ipv6.conf.default.disable_ipv6=1 ``` 临时开启ipv6命令 ``` sysctl -w net.ipv6.conf.all.disable_ipv6=0 sysctl -w net.ipv6.conf.default.disable_ipv6=0 ``` 永久关闭系统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 ``` 或者编辑系统内核配置文件 ``` vi /etc/sysctl.conf //编辑系统内核文件,添加以下代码 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 ``` 永久开启系统的ipv6,把上面代码的1改为0即可。。。 查看系统ipv6状态命令 ``` cat /proc/sys/net/ipv6/conf/all/disable_ipv6 cat /proc/sys/net/ipv6/conf/default/disable_ipv6 ``` 返回0表示启用,1则表示禁用ipv6 Last modification:August 12, 2021 © Allow specification reprint Like 2 如果觉得我的文章对你有用,请随意赞赏