CentOS系统下如何禁用IPv6网络?(解决安装AppNode卡死问题)

虚竹 2018-3-4 1163

我们发现有一些 CentOS 系统的服务器,虽然启用了 IPv6,但实际上机房的网络并不支持 IPv6,这就导致在下载安装 AppNode 时出现卡死,或安装受控端时出现“连接超时,请重新连接...”的错误:



您可以根据下文检测并修复,如果确实是因为这个问题造成的安装卡死,建议将这个问题反馈给机房改进(顺便索要点优惠啥的哈哈)。

如何检测确认是因为这个原因造成的?


使用以下curl命令测试,如果出现 Trying IPv6 地址的字样,说明就是这个原因造成的,如下:

# curl -vod http://dl.appnode.com/
* About to connect() to dl.appnode.com port 80 (#0)
*   Trying 2600:9000:202a:5400:c:c81d:6840:21... Timeout
*   Trying 2600:9000:202a:fe00:c:c81d:6840:21... Timeout


正常的输出应该是:

# curl -vod >http://dl.appnode.com
* About to connect() to dl.appnode.com port 80 (#0)
*   Trying 52.85.5.46... connected
* Connected to dl.appnode.com (52.85.5.46) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: dl.appnode.com
> Accept: */*
> 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
< HTTP/1.1 403 Forbidden
< Content-Type: application/xml
< Content-Length: 255
< Connection: keep-alive
< Server: AliyunOSS
< Date: Sun, 04 Mar 2018 04:34:09 GMT
< x-oss-request-id: 5A9B774162AA8938188F4384
< x-oss-server-time: 38
< Age: 270
< X-Cache: Error from cloudfront
< Via: 1.1 c292a111f9c647cf9b2b917e4d8225b6.cloudfront.net (CloudFront)
< X-Amz-Cf-Id: iGDMBevcdrx5FcHC74bIgJ-W0SXQUYyvO0FqbYpPbMfKrITGaMYAkQ==
< 
{ [data not shown]
127   255  127   255    0     0    294      0 --:--:-- --:--:-- --:--:--   923
* Connection #0 to host dl.appnode.com left intact

* Closing connection #0


解决办法


使用以下命令禁用 IPv6:

cat >> /etc/sysctl.conf <<EOF
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
EOF


禁用完成后重启系统才会生效。

请注意,不要直接禁用 IPv6 模块,可能会引起其它问题:

If you don't want to use IPv6, do not disable loading the IPv6 module, as doing that can cause other problems. There is a better way to get rid of IPv6 if you need to. See the FAQ entry for details.
最新回复 (0)
返回
发新帖