思路
- 修改hosts,直接访问最快的CDN节点
- 通过镜像去访问
方式1: 修改hosts文件
查找GitHub域名的IP地址
我们可以利用https://www.ipaddress.com/ 来获得以下以下GitHub域名的IP地址:
github.global.ssl.fastly.net
github.com
assets-cdn.github.com
documentcloud.github.com
gist.github.com
help.github.com
nodeload.github.com
codeload.github.com
raw.github.com
status.github.com
training.github.com
avatars0.githubusercontent.com
avatars1.githubusercontent.com
avatars2.githubusercontent.com
avatars3.githubusercontent.com
打开网页后,利用输入框内分别查询以上域名后,得到相应的IP
hosts
文件中添加一下配置
hosts
文件路径
mac: /etc/hosts
win: C:\WINDOWS\system32\drivers\etc\hosts
# GitHub Start 140.82.113.4 github.com 140.82.114.4 github.com 140.82.113.4 gist.github.com 140.82.113.6 api.github.com 185.199.108.153 assets-cdn.github.com 185.199.109.153 assets-cdn.github.com 185.199.110.153 assets-cdn.github.com 185.199.111.153 assets-cdn.github.com 199.232.96.133 raw.githubusercontent.com 199.232.96.133 gist.githubusercontent.com 199.232.96.133 cloud.githubusercontent.com 199.232.96.133 camo.githubusercontent.com 199.232.96.133 avatars.githubusercontent.com 199.232.96.133 avatars0.githubusercontent.com 199.232.96.133 avatars1.githubusercontent.com 199.232.96.133 avatars2.githubusercontent.com 199.232.96.133 avatars3.githubusercontent.com 199.232.96.133 avatars4.githubusercontent.com 199.232.96.133 avatars5.githubusercontent.com 199.232.96.133 avatars6.githubusercontent.com 199.232.96.133 avatars7.githubusercontent.com 199.232.96.133 avatars8.githubusercontent.com 199.232.96.133 user-images.githubusercontent.com # GitHub End
刷新 DNS 存**
在终端或CMD中,执行以下命令:
ipconfig /flushdns
备注
https://gitee.com/bryan31/githubhost
自动选取并生成github最快CDN IP的小工具,生成后贴到hosts文件即可
方式2: 镜像方式
参考链接:
https://segmentfault.com/a/1190000023735638
https://www.jianshu.com/p/0493dcc15d6f