无法访问raw.githubusercontent.com解决办法

在云服务器上装nvm发现安装脚本报错,提示Failed to connect to ::: No route to host无法访问raw.githubusercontent.com

[root@ecs-09077087-007 ~]# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to ::: No route to host

ping raw.githubusercontent.com发现被重定向到了127.0.0.1

[root@ecs-09077087-007 ~]# ping raw.githubusercontent.com
PING raw.githubusercontent.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.037 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.037 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.038 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.020 ms
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.026 ms
64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.026 ms
^C
--- raw.githubusercontent.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7009ms
rtt min/avg/max/mdev = 0.014/0.027/0.038/0.010 ms

raw.githubusercontent.com.jpg
可以看到受墙影响国内抽风的还是比较厉害的,根据ipaddress.com查询raw.githubusercontent.com地址

Q:What IP addresses does raw.githubusercontent.com resolve to?
A:raw.githubusercontent.com resolves to 4 IPv4 addresses and 4 IPv6 addresses:
185.199.108.133
185.199.109.133
185.199.110.133
185.199.111.133
2606:50c0:8000::154
2606:50c0:8001::154
2606:50c0:8002::154
2606:50c0:8003::154

在云服务器上选择延迟较低的地址写入hosts文件

[root@ecs-09077087-007 ~]# vi /etc/hosts
185.199.108.133 raw.githubusercontent.com

再ping raw.githubusercontent.com可以看到已经ping通了

[root@ecs-09077087-007 ~]# ping raw.githubusercontent.com
PING raw.githubusercontent.com (185.199.108.133) 56(84) bytes of data.
64 bytes from raw.githubusercontent.com (185.199.108.133): icmp_seq=1 ttl=43 time=83.5 ms
64 bytes from raw.githubusercontent.com (185.199.108.133): icmp_seq=2 ttl=43 time=80.9 ms
64 bytes from raw.githubusercontent.com (185.199.108.133): icmp_seq=3 ttl=43 time=89.1 ms
64 bytes from raw.githubusercontent.com (185.199.108.133): icmp_seq=4 ttl=43 time=78.0 ms
^C
--- raw.githubusercontent.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3010ms
rtt min/avg/max/mdev = 78.028/82.919/89.175/4.115 ms

BTW国内访问github不稳定,推荐个利器dev-sidecar

添加新评论