本文共 729 字,大约阅读时间需要 2 分钟。
CentOS7优先选择使用IPv4
现在大多数情况下IPv6是不能关掉的,很多程序比如grpc等等都是强依赖IPv6的,并且现在好多APP也需要支持IPv6,但是很多服务器IPv6网络是不通的。
就会出现如下的情况
[root@ipcpu-xops ~]# yum search zabbixLoaded plugins: fastestmirrorhttp://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2604:a880:1:20::b82:1001: Network is unreachable"Trying other mirror.http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2604:a880:1:20::b82:1001: Network is unreachable"Trying other mirror.
如何让这些程序优先走IPv4呢?
其实有个配置文件 /etc/gai.conf,这个文件默认不存在的,需要自己创建。
内容如下
precedence ::ffff:0:0/96 100
默认的帮助文件在这里:
/usr/share/doc/glibc-common-2.17/gai.conf参考资料
转载于:https://blog.51cto.com/ipcpu/2389155