- 查看是否开启IPV6
结果中显示inet6,表示开启了IPV6
[hadoop@zbx-server-agent ~]$ ip addr
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:d7:c8:d5 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.144/24 brd 192.168.100.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::a8ed:bce0:dedf:8607/64 scope link noprefixroute
valid_lft forever preferred_lft forever
- 编辑/etc/sysctl.conf
添加 net.ipv6.conf.all.disable_ipv6=1
[hadoop@zbx-server-agent ~]$ sudo cat /etc/sysctl.conf
sysctl settings are defined through files in
/usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
Vendors settings live in /usr/lib/sysctl.d/.
To override a whole file, create a new file with the same in
/etc/sysctl.d/ and put new settings there. To override
only specific settings, add a file with a lexically later
name in /etc/sysctl.d/ and put new settings there.
For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv6.conf.all.disable_ipv6=1
- 编辑/etc/sysconfig/network
增加 NETWORKING_IPV6=no
[hadoop@zbx-server-agent ~]$ sudo cat /etc/sysconfig/network
Created by anaconda
NETWORKING_IPV6=no
- 编辑/etc/sysconfig/network-scripts/ifcfg-ens33
sudo sed -i 's#IPV6INIT=yes#IPV6INIT=no#' /etc/sysconfig/network-scripts/ifcfg-ens33
[hadoop@zbx-server-agent ~]$ sudo cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=18f30053-d1e0-4cbf-8048-c1f826d8eada
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.144
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
DNS1=114.114.114.114
DNS2=218.2.135.1
5.重新加载sysctl -p 或重启
sudo sysctl -p
[hadoop@zbx-server-agent ~]$ sudo sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
6.查看效果
[hadoop@zbx-server-agent ~]$ ip addr
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
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d7:c8:d5 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.144/24 brd 192.168.100.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever