禁用ipv6的两种方法

1 通过系统配置文件/etc/sysctl.conf

     在sysctl.conf文件中添加行

     

  • # 禁用整个系统所有接口的IPv6
  • net.ipv6.conf.all.disable_ipv6 = 1

   

  • # 禁用某一个指定接口的IPv6(例如:eth0, lo)
  • net.ipv6.conf.lo.disable_ipv6 = 1
  • net.ipv6.conf.eth0.disable_ipv6 = 1
  • 在 /etc/sysctl.conf 使这些更改生效,运行以下命令:
    1. $ sudo sysctl -p /etc/sysctl.conf

2 通过内核启动时,传递内核参数

   

用文本编辑器打开 /etc/default/grub 并给GRUBCMDLINELINUX变量添加"ipv6.disable=1"。

  1. $ sudo vi /etc/default/grup

  1. GRUB_CMDLINE_LINUX="xxxxx ipv6.disable=1"

 

posted @ 2017-11-27 21:42  yaocai  阅读(10265)  评论(0编辑  收藏  举报