IPv6是下一代因特网协议,设计来取代当前的因特网协议,需要用于两个设备之间的通信的IP版本4的IP地址。它是一台计算机通过互联网的身份。 本文将帮助你从你的Linux机器禁用IPv6。
1. 检查IPv6地址
使用
ifconfig命令来查看系统上当前的IPv6地址。你会得到的结果类似下面。
[root@youcl.com ~]# ifconfig
eth0: flags=4163<up,broadcast,running,multicast> mtu 1500
inet 45.55.65.94 netmask 255.255.224.0 broadcast 45.55.95.255
inet6 fe80::601:92ff:fe35:ea01 prefixlen 64 scopeid 0x20<link>
ether 04:01:92:35:ea:01 txqueuelen 1000 (Ethernet)
RX packets 2411381 bytes 794420295 (757.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2151232 bytes 351005391 (334.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<up,broadcast,running,multicast> mtu 1500
inet6 fe80::601:92ff:fe35:ea02 prefixlen 64 scopeid 0x20<link>
ether 04:01:92:35:ea:02 txqueuelen 1000 (Ethernet)
RX packets 8 bytes 648 (648.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 123828 bytes 21997128 (20.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<up,loopback,running> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 47584 bytes 4822673 (4.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 47584 bytes 4822673 (4.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2. 暂时禁用IPv6
如果要禁用IPv6当前会话,只需使用下面的命令来设置运行时间变量。请记住下面的变化将是系统重新启动后丢弃恢复。
$ sudo echo "1" > /proc/sys/net/ipv6/conf/all/disable_ipv6
3. 永久禁用IPv6
要永久禁用IPv6,编辑/etc/sysctl.conf文件,并添加/更新以下参数
$ 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
并使用以下命令重新装入sysctl的配置
$ sudo sysctl -p