关闭IPV6-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

关闭IPV6

简介: IPV6的关闭
  1. 查看是否开启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
  1. 编辑/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

  1. 编辑/etc/sysconfig/network

增加 NETWORKING_IPV6=no
[hadoop@zbx-server-agent ~]$ sudo cat /etc/sysconfig/network

Created by anaconda

NETWORKING_IPV6=no

  1. 编辑/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

7.参考文档
https://www.cnblogs.com/zhoading/p/11639204.html

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章
最新文章
相关文章