GitHub-Tutorial icon indicating copy to clipboard operation
GitHub-Tutorial copied to clipboard

GitHub 访问加速方法

Open CatOneTwo opened this issue 4 years ago • 0 comments

国内的 GitHub 无论是打开,还是下载都挺慢,我参考网上的方法修改 host 文件,提升了速度(这是 2020/6/12 写的,目前有效)

1. 打开 hosts 文件

首先打开路径 C:\Windows\System32\drivers\etc 下的 hosts 文件(可以右击以管理员身份打开,保存不了可以右击修改 hosts 的读写属性),等会儿我们会修改该文件。

注意:

windows系统的hosts文件的位置如下:C:\Windows\System32\drivers\etc\hosts

mac/linux系统的hosts文件的位置如下:/etc/hosts

在这里插入图片描述

2. 查询 IP

然后打开网页 https://www.ipaddress.com/ip-lookup

在输入框分别输入下面五个名称,查询它们对应的 IP 地址:

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

比如查询 github.com 的地址,输入后点击 Look up

image-20200612094531789

网页会返回 IP:

image-20200612094717058

把这个 IP 记下来,当前页面下拉到最底下,可以接着查询下一个。

image-20200612094839478

❗要注意:查询第四个 assets-cdn.github.com 的 IP 时会返回四个,我们得一个个试一下哪个能用:

image-20200612095145779

方法是 Windows +R 打开运行,然后输入 cmd ,点击回车,在 cmd 里面依次 ping 四个 IP(输入 ping ,后面跟 IP,如果访问太慢,ctrl + C 结束 ping),返回超时的不选,可以多试几次,选稳定的平均时间最短的那个:

image-20200612095541953最后我们就得到了五个 IP ,这都是一个个查出来的,复制别人的没用哈:

在这里插入图片描述

3. 修改 hosts 文件

回到我们刚刚打开的 host 文件:

把刚刚查到的五个IP 复制到文件最末端

140.82.112.4 github.com
140.82.113.3 gist.github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.111.153 assets-cdn.github.com
199.232.68.133 raw.githubusercontent.com

除了这五个,还要再加上下面的 IP,它们和第五个 IP 地址是一样的:

199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.68.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

最后我们的 hosts 文件添加如下内容,点击保存(保存不了就右击文件,打开属性修改 hosts 的读写权限)

image-20200612101245843

4. 刷新 DNS

打开 cmd 输入下代码刷新 DNS:

ipconfig /flushdns

最后刷新自己的 GitHub,打开各个页面会快一些~


返回目录:GitHub 入门教程

CatOneTwo avatar Jun 12 '20 02:06 CatOneTwo