解决GitHub网页githubusercontent地址没法访问问题

去年年末开始GitHub里面的用户头像没法显示,页面也加载缓慢,这下快乐的日子可能一去不复返了,咱们须要把相关域名加加速了。git

GitHub里面图片都在githubusercontent.com域名上,咱们只须要在hosts里面加上相关地址便可。若是你有代理,把域名加入到许可名单也能够的。github

这里咱们介绍hosts方式是如何使用的,把如下内容添加到hosts文件中。shell

1. hosts内容

# 2020年12月30日更新

# GitHub Start
52.74.223.119     github.com
52.74.223.119   gist.github.com
54.169.195.247   api.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   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
185.199.109.154   github.githubassets.com
# GitHub End
注意 : 这里域名对应的ip是经过dns查询工具查询获得的,你应当选择的是延时相对较小且比较稳定的ip。

若是发现不起做用,或者速度不理想,参考查找域名IPwindows

2. 如何修改

这里推荐使用 SwitchHosts! 配置hosts,操做很简单,支持跨平台。api

复制前面的hosts内容到软件里配置便可,相关介绍参考下面文章。缓存

SwitchHosts! 还能这样管理hosts,后悔没早点用工具

2.1 Windows

hosts文件位置:C:/windows/system32/drivers/etc/hosts测试

将前文内容追加到hosts,而后刷新DNS缓存:代理

ipconfig /flushdns

2.2 Mac

hosts文件位置:/etc/hostscode

Mac系统下修改须要按照以下方式:

1:首先,打开(访达)Finder。
2:使用组合键Shift+Command+G打开"前往文件夹",在输入框输入/etc/hosts
3:而后就会跳转到hosts文件位置。

复制hosts文件到桌面上,鼠标右键点击/右击它,选择「打开方式」—「文本编辑」,打开这个hosts文件,而后将你要修改的内容直接在里面修改就行了。

而后把你修改好的hosts文件在复制回hosts文件的所在(文件夹下)路径:/etc/hosts 之下替换原始的hosts文件就行了。

注意:若是弹出密码输入框,你须要输入你当前电脑登陆帐号的密码。

最后刷新下缓存:

sudo killall -HUP mDNSResponder

3. 查找域名IP

注:2020年12月30日我实际使用 IPAddress才能够生效,前面两个查询站点获取的 IP均没法使用,各位能够都尝试下直到生效。

前面hosts里面域名里分为两类:

  • *.githubusercontent.com
  • *.github.com

*.githubusercontent.com可使用同一个IP,不须要每一个单独查询。*.github.com未经测试,目前看是须要单独查询对应的IP

相关文章
相关标签/搜索