CentOS7 关闭ipv6

1.在/etc/sysctl.conf添加以下1行

echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
sysctl -p

2.ifconfig查看没有ipv6了

[root@controller ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        ether fa:16:3e:8b:77:3b  txqueuelen 1000  (Ethernet)
        RX packets 1267490  bytes 919538713 (876.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 216258  bytes 729206988 (695.4 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
        loop  txqueuelen 1  (Local Loopback)
        RX packets 16  bytes 1096 (1.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 1096 (1.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3.重启后发现有ipv6的话,修改/etc/default/grub配置文件

[root@controller ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet ipv6.disable=1" ##在quiet后面添加ipv6.disable=1

[root@controller ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
[root@controller ~]# reboot
			        	

未经允许不得转载:Linux备忘录 » CentOS7 关闭ipv6

猜你喜欢

转载自blog.csdn.net/u011084922/article/details/107482676
今日推荐