IPv6在未来可能成为主流,但是就目前而言,很多软件对IPv6的支持并不是很完善,可能导致各类问题。RHEL 7 & CentOS 7 在启动时默认是加载IPv6相关模块的,而禁用IPV6的方法与之前的版本有点不太一样了,现在我们来探讨一下如何彻底禁用IPv6的方法,修改grub,在系统启动引导时就不加载IPv6模块。希望对大家有所帮助。
52 cd /proc/sys/net/ipv6/conf #在这个conf目录下一共有三个all、default、ens33 [root@localhost conf]# cat all/disable_ipv6 0 [root@localhost conf]# cat default/disable_ipv6 0 [root@localhost conf]# cat ens33/disable_ipv6 0
2.ipv6现在处于开启状态,现在进行临时关闭:
[root@localhost conf]# echo "1" >all/disable_ipv6 [root@localhost conf]# cat all/disable_ipv6 1 [root@localhost conf]# echo "1" >default/disable_ipv6 [root@localhost conf]# echo "1" >ens33/disable_ipv6 [root@localhost conf]# cat default/disable_ipv6 1 [root@localhost conf]# cat ens33/disable_ipv6 1
3.查看ipv6相关模块(这些模块存在就证明ipv6开启着)
[root@localhost conf]# lsmod |grep ipv6 nf_reject_ipv6 13717 1 ip6t_REJECT nf_conntrack_ipv6 18935 7 nf_defrag_ipv6 35104 1 nf_conntrack_ipv6 nf_nat_ipv6 14131 1 ip6table_nat nf_nat 26787 2 nf_nat_ipv4,nf_nat_ipv6 nf_conntrack 133387 6 nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_conntrack_ipv4,nf_conntrack_ipv6
现在我们来永久关闭ipv6(修改grub,在系统启动引导时就不加载IPv6模块)
[root@localhost ~]# cd /etc/default/ [root@localhost default]# cat grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed ‘s, release .*$,,g‘ /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"
添加ipv6.disable=1然后重新生成grub:
[root@localhost default]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-7eed5aace09049b58b59fca1495d967a Found initrd image: /boot/initramfs-0-rescue-7eed5aace09049b58b59fca1495d967a.img done
重启后查看:什么也不显示就证明模块没有加载
[root@localhost default]# reboot [root@localhost ~]# lsmod |grep ipv6 [root@localhost ~]#
原文:https://www.cnblogs.com/cy888888/p/14080678.html