1
sudo vim /etc/hosts

  

一般联通宽带出现这样的情况比较多,命令行访问github网速基本在2kb/s左右。拉个项目都成问题。

最后百度解决了问题,记录一下。

打开终端,编辑hosts文件

 

添加以下内容

# Github
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
151.101.185.194 github.global.ssl.fastly.net
192.30.253.112 github.com
151.101.112.133 assets-cdn.github.com
151.101.184.133 assets-cdn.github.com
185.199.108.153 documentcloud.github.com
192.30.253.118 gist.github.com
185.199.108.153 help.github.com
192.30.253.120 nodeload.github.com
151.101.112.133 raw.github.com
23.21.63.56 status.github.com
192.30.253.1668 training.github.com
192.30.253.112 www.github.com
151.101.13.194 github.global.ssl.fastly.net
151.101.12.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com

  

刷新dns

1
dscacheutil -flushcache

  

Mac 无法访问github

最近又遇到一个新的问题,无法访问github.com。测试ping github.com。

1
2
3
4
5
PING github.com (192.30.253.112): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

  

发现hosts里面的192.30.253.112 ip地址已经无法ping通。

通过查看 https://github.com.ipaddress.com ,发现github.com地址已经变成了140.82.114.4。

 

通过ping 140.82.114.4,发现可以成功连通。而且能看到丢包率。

PING 140.82.114.4 (140.82.114.4): 56 data bytes
64 bytes from 140.82.114.4: icmp_seq=0 ttl=50 time=273.171 ms
Request timeout for icmp_seq 1
64 bytes from 140.82.114.4: icmp_seq=2 ttl=50 time=349.876 ms
64 bytes from 140.82.114.4: icmp_seq=3 ttl=50 time=373.356 ms
64 bytes from 140.82.114.4: icmp_seq=4 ttl=50 time=317.572 ms
64 bytes from 140.82.114.4: icmp_seq=5 ttl=50 time=273.282 ms
ç64 bytes from 140.82.114.4: icmp_seq=6 ttl=50 time=274.258 ms
^C
--- 140.82.114.4 ping statistics ---
7 packets transmitted, 6 packets received, 14.3% packet loss
round-trip min/avg/max/stddev = 273.171/310.252/373.356/40.090 ms

所以又继续编辑hosts文件,将github.com改成

1
140.82.114.4 github.com

  

最后测试

浏览器访问 https://github.com 就能正常了。

总结

目前都是本地hosts配置了github.com 的ip地址,如果访问github失败,或者访问网速慢,可能就是github的ip地址换了或者ip地址丢包严重。可以通过ping github.com 查看时长以及丢包率。

如果需要修改github ip地址,可以通过 https://github.com.ipaddress.com ,了解当前github.com的ip地址。

最后修改本地hosts中的配置,再刷新dns即可。

 

posted on   ygunoil  阅读(1948)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示