admin avatar

Debian 10 how to turn IPv6 on and off

🕑 by admin





Debian way to turn on and off IPv6

Check if the system has ipv6 kernel loaded

lsmod | grep ipv6

Return data similar to the following, it means that the ipv6 kernel is loaded

1
2
3
4
5
6
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

Check if there is an IPv6 address

1
2
3
ifconfig 
ip address list
netstat -anptl

Command to temporarily close ipv6

1
2
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

Temporarily open the ipv6 command

1
2
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0

Permanently shut down the system ipv6

1
2
3
4
5
6
7
8
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

Or edit the system kernel configuration file

1
2
3
4
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

Open the system's ipv6 permanently, and change the 1 in the above code to 0. . .

View system ipv6 status command

1
2
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
cat /proc/sys/net/ipv6/conf/default/disable_ipv6

Return 0 to enable, 1 to disable ipv6





💘 相关文章

写一条评论

Based on Golang + fastHTTP + sdb | go1.18.3 Processed in 2ms