天天看點

CentOS 7 關閉IP v6

檢視網絡情況

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state
UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP group default qlen 1000
    link/ether 00:0c:29:bc:2c:67 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::cb2b:20f:70fb:d627/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
           

看到inet6的内容,就表示系統啟用了ipv6的支援。

編輯 /etc/sysctl.conf

net.ipv6.conf.ens33.disable_ipv6 = 1
           

讓修改馬上生效。需要注意的是你的網卡名字,現在都已經不是eth0,ens33,我的虛拟機。

# sysctl -p
net.ipv6.conf.ens33.disable_ipv6 = 1           
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue
state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:bc:2c:67 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.10/24 brd 192.168.200.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever           

對比一下就能看到差別。

參考文章

https://www.thegeekdiary.com/centos-rhel-7-how-to-disable-ipv6-on-a-specific-interface-only/

繼續閱讀