runsisi's

technical notes

禁用 IPv6

2019-02-28 runsisi#ipv6

现在的 Linux 发行版默认会启用 IPv6 支持,但在某些场景下,可能需要禁用 IPv6 进行测试。

临时禁用 IPv6,重启失效

~# sysctl net.ipv6.conf.all.disable_ipv6=1
~# sysctl net.ipv6.conf.default.disable_ipv6=1
~# sysctl net.ipv6.conf.lo.disable_ipv6=1

加入到系统配置文件中,重启后生效

~# 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 -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

验证是否已生效

~$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
~$ cat /proc/sys/net/ipv6/conf/default/disable_ipv6
~$ cat /proc/sys/net/ipv6/conf/lo/disable_ipv6

参考资料

How To Disable IPV6 on Linux/Ubuntu?

https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu

How-To: Disable IPV6 to speed up Internet.

https://ubuntuforums.org/showthread.php?t=87798

What is module net-pf-10 ?

https://www.redhat.com/archives/redhat-list/2002-January/msg03125.html