为什么 ping 可以正常工作而 curl 却无法从 cache.ruby-lang.org 下载?

为什么 ping 可以正常工作而 curl 却无法从 cache.ruby-lang.org 下载?

我有一个类似的问题: Wget、Curl、Yum 失败但 Ping 可用 - CentOS 5

就我而言,我有 2 台 Ubuntu 18.04 服务器无法从 cache.ruby-lang.org 下载:

curl -O https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.bz2 -v
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 151.101.1.178...
* TCP_NODELAY set
* Connected to cache.ruby-lang.org (151.101.1.178) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
  0     0    0     0    0     0      0      0 --:--:--  0:04:59 --:--:--     0* Operation timed out after 300334 milliseconds with 0 out of 0 bytes received
* stopped the pause stream!
  0     0    0     0    0     0      0      0 --:--:--  0:05:00 --:--:--     0
* Closing connection 0
curl: (28) Operation timed out after 300334 milliseconds with 0 out of 0 bytes received

但是,ping cache.ruby-lang.org 可以正常工作:

ping cache.ruby-lang.org
PING dualstack.m.shared.global.fastly.net (151.101.1.178) 56(84) bytes of data.
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=1 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=2 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=3 ttl=60 time=51.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=4 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=5 ttl=60 time=50.9 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=6 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=7 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=8 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=9 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=10 ttl=60 time=50.8 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=11 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=12 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=13 ttl=60 time=50.5 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=14 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=15 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=16 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=17 ttl=60 time=50.8 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=18 ttl=60 time=50.8 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=19 ttl=60 time=50.8 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=20 ttl=60 time=50.8 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=21 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=22 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=23 ttl=60 time=50.9 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=24 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=25 ttl=60 time=50.7 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=26 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=27 ttl=60 time=50.6 ms
64 bytes from 151.101.1.178 (151.101.1.178): icmp_seq=28 ttl=60 time=50.5 ms
^C
--- dualstack.m.shared.global.fastly.net ping statistics ---
28 packets transmitted, 28 received, 0% packet loss, time 27048ms
rtt min/avg/max/mdev = 50.518/50.790/51.781/0.371 ms

卷曲适用于其他 URL,例如https://www.google.com

并且,在我本地的 Ubuntu 18.04 VM 上,使用 Curl 命令下载 Ruby 运行良好,因此看起来 2 台故障机器的位置(孟加拉国)和我所在的位置(加拿大)存在一些差异。

我已将服务器的 IP 地址放入几个在线信誉检查网站,结果显示这些服务器并未被列入黑名单,所以我不知道为什么我无法访问 cache.ruby-lang.org 进行这些下载。

我已经确认孟加拉国的服务器和我的个人虚拟机上都安装了相同版本的 Curl(7.58)。

tcptraceroute 似乎表明 TCP 正在运行:

sudo tcptraceroute cache.ruby-lang.org
Running:
    traceroute -T -O info cache.ruby-lang.org 
traceroute to cache.ruby-lang.org (151.101.1.178), 30 hops max, 60 byte packets
 1  123.49.37.81 (123.49.37.81)  0.529 ms  0.482 ms  0.488 ms
 2  * * 123.49.60.89 (123.49.60.89)  4.168 ms
 3  * * *
 4  54113.sgw.equinix.com (27.111.228.34)  54.650 ms  54.649 ms  54.637 ms
 5  151.101.1.178 (151.101.1.178) <syn,ack>  54.606 ms  54.592 ms  54.573 ms

我还可以检查什么?

答案1

它不能解决这个问题,但是 - 你是否尝试过使用其他官方镜像? 因为 Fastly CDN 似乎有一些地理限制,所以我建议也写信给支持人员https://support.fastly.com/hc/en-us/requests/new

答案2

尝试在服务器上设置此DNS地址:[8.8.8.8,8.8.4.4]。

相关内容