CentOS/RHEL 6 系统默认启用 IPv6.
但是,如果它由于某种原因被禁用,我们可以按照下面的简短操作方法重新启用它。
基本上有两种方法可以在 CentOS/RHEL 6 上禁用 IPv6.
- 在内核模块中禁用 IPv6(需要重新启动)
- 使用 sysctl 设置禁用 IPv6(不需重新启动)
方法1:使用/etc/modprobe.d/ipv6.conf(需要重启)
- 确认是否使用ipv6.
如果没有显示带有 inet6 的行,则不使用 IPV6.
# ifconfig |grep inet6 #
2.修改配置文件/etc/modprobe.d/*.conf或者/etc/modprobe.conf,防止内核加载ipv6模块
# grep ipv6 /etc/modprobe.conf /etc/modprobe.d/*.conf /etc/modprobe.d/ipv6.conf:1:options ipv6 disable=1 ### we need to remove this line
删除(或者散列)以上行后,验证:
# cat /etc/modprobe.d/ipv6.conf # options ipv6 disable=1
3.如果需要,启用ip6tables服务
# chkconfig ip6tables on
- 重启
# shutdown -r now
- 验证我们现在是否可以在 ifconfig 命令输出中看到 inet6 行。
# ifconfig |grep inet6 inet6 addr: 2405:200:a60:fd00:250:56ff:fe96:f0e/64 Scope:Global inet6 addr: fe80::250:56ff:fe96:f0e/64 Scope:Link inet6 addr: ::1/128 Scope:Host
欢迎来到之路教程(on itroad-com)
方法2:使用/etc/sysctl.conf(在线)
- 将以下行添加到文件 /etc/sysctl.conf。
# vi /etc/sysctl.conf # IPv6 support in the kernel, set to 0 by default net.ipv6.conf.all.disable_ipv6 = 0 net.ipv6.conf.default.disable_ipv6 = 0
- 要应用对当前 sysctl 参数的更改,请执行:
# sysctl -p
- 使用'sysctl -a' 来验证参数值。
# sysctl -a | grep net.ipv6.conf net.ipv6.conf.all.disable_ipv6 = 0 net.ipv6.conf.default.disable_ipv6 = 0
日期:2020-09-17 00:13:35 来源:oir作者:oir