在度娘上找了很多解决方案,殊途同归,基本都是修改系统hosts文件,绕过国内dns解析,直接访问GitHub的CDN节点。只不过解析对应的链接大都不全,故在此记录分享完整版的dns解析地址。

前一段时间在github上想clone一个项目代码,下载速度3kb/s,并且Readme.md页面还无法加载图片。虽然以前也很慢,大概100kb/s的样子,但这个3kb/s着实过分😒。

(推荐)法一:油猴github镜像脚本插件

一、下载脚本插件管理器

在油猴官网https://greasyfork.org/zh-CN下载一个脚本插件管理器
*推荐Chrome + Tampermonkey *

GreasyFork

二、下载github镜像插件

插件下载地址:https://greasyfork.org/zh-CN/scripts/397419-github镜像加速访问-克隆和下载

Github镜像插件

安装完成后在https://github.com/RC1844/FastGithub上展示的github镜像站中按需选择镜像
注意不要拿自己账号登录镜像站

Github镜像站点

然后在镜像站中搜索仓名 或 直接在镜像域名后加上/用户名/仓名跳转,下载或克隆所需即可
此处以https://github.wuyanzheshui.workers.dev和PicGo的图床releases下载为例

法二:更改默认DNS

只想要hosts修改结果的,请直接移步此处

一、获取GitHub官方CDN地址

打开 https://www.ipaddress.com/
查询以下链接的地址

github.com
gist.github.com
assets-cdn.github.com
github.global.ssl.fastly.net

cloud.githubusercontent.com(注意这条Domain的IP会重复用到)
Github官方CDN地址
记录下查询到的ip地址

二、修改系统Hosts文件

用记事本打开系统hosts文件(需管理员权限)
路径:C:\Windows\System32\drivers\etc
记事本末尾添加IP地址 域名并保存。(需管理员权限,注意IP地址与域名间需留有空格)
不必按照我下面的完全复制,github可能随时间更换ip地址,尽量按照自己查询到的为准
注意不要删掉或覆盖原本的hosts内容

140.82.114.3 github.com
140.82.112.4 gist.github.com
185.199.108.153 assets-cdn.github.com
199.232.69.194 github.global.ssl.fastly.net

(以下所有子域名的Domain都是githubusercontent.com,故ip完全一致不用重复查询)
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.68.133 raw.githubusercontent.com
199.232.68.133 gist.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com

三、刷新系统DNS缓存

win + R 打开命令行或 win + X 打开powershell
输入并运行 ipconfig /flushdns 手动刷新系统DNS缓存

刷新系统DNS缓存
现在尝试重新clone和刷新页面,clone速度应当一定程度上提高了,图片可以加载出来。

四、如果无效/提速不够

不太可能完全无效,但如果觉得速度还是太慢,你就还是需要一个SSR或者VPN了,推荐环日+ShadowsocksR,多的不说了= =。