之前写了一篇彻底解决 GitHub git clone 卡慢,那个的前提是科学,科学里配置都是ip的话,没有dns也能正常工作。这篇文章是建立在GitHub没有被墙的前提下,hosts没有加速功能,他仅仅是为了让你正确识别GitHub的ip。

hosts

依据:查询Hosts文件得到的结果比通过查询DNS得到的结果优先级更高。

Windows 系统:C:\Windows\System32\drivers\etc\hosts

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
32
33
# GitHub520 Host Start
185.199.108.154 github.githubassets.com
140.82.114.21 central.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.153 assets-cdn.github.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 github.map.fastly.net
199.232.69.194 github.global.ssl.fastly.net
140.82.113.3 gist.github.com
185.199.108.153 github.io
140.82.113.4 github.com
140.82.112.5 api.github.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars.githubusercontent.com
140.82.114.10 codeload.github.com
52.217.73.244 github-cloud.s3.amazonaws.com
52.216.164.131 github-com.s3.amazonaws.com
52.216.200.3 github-production-release-asset-2e65be.s3.amazonaws.com
52.217.81.140 github-production-user-asset-6210df.s3.amazonaws.com
52.217.80.164 github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.108.153 githubstatus.com
64.71.168.201 github.community
185.199.108.133 media.githubusercontent.com
# Star me GitHub url: https://github.com/521xueweihan/GitHub520
# GitHub520 Host End

更新地址:

https://github.com.cnpmjs.org/521xueweihan/GitHub520

https://hub.fastgit.org/521xueweihan/GitHub520

DNS

当然你的GitHub Pages也要写入hosts,比如185.199.108.153 weilining.github.io,如果觉得麻烦,可以更改DNS,来达到获得正确ip的目的。

最优雅的设置DNS

阿里云公共DNS:https://www.alidns.com

腾讯云公共DNS:https://www.dnspod.cn/Products/Public.DNS

电信联通移动通用DNS:https://www.114dns.com/

谷歌公共DNS:https://developers.google.com/speed/public-dns

cloudflareDNS:https://1.1.1.1/zh-Hant/dns/

参考

https://zh.wikipedia.org/wiki/Hosts%E6%96%87%E4%BB%B6

https://zh.wikipedia.org/wiki/%E5%9F%9F%E5%90%8D%E7%B3%BB%E7%BB%9F

https://github.com/521xueweihan/GitHub520