Github打开慢的原因:
DNS解析的问题;
服务器在国外。
解决方案:
修改本地host文件,增加配置内容,绕过域名解析,达到加速的目的。
操作步骤:
1、找见hosts文件
Windows:
C:\Windows\System32\drivers\etc\hosts
Mac\Linux:
/etc/hosts
2、在文件末尾追加内容(一般情况下,复制下面的内容到hosts中即可)
199.232.69.194 github.global.ssl.fastly.net
140.82.113.3 github.com
185.199.108.154 github.githubassets.com
3、刷新dns缓存,在cmd中输入 ipconfig/flushdns
4、Github的IP地址是不断变化的,如果发现网站打不开了,可以获取新的IP地址修改hosts里面的内容。
DEMO:(ubuntu)
打开终端命令行,输入命令:sudo gedit /etc/hosts 打开hosts文件,修改里面的内容如下
127.0.0.1 localhost
127.0.1.1 intasect-HP-Desktop-Pro-G2-MT
xxx.xxx.xxx.xxx github.com git
13.250.177.223 github.com
# github.com
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.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
151.101.113.194 github.global.ssl.fastly.net
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
上面的xxx.xxx.xxx.xxx 是本机的ipv4地址, 13.250.177.223 是利用站长工具,获取的github数据库的ipv4地址。
可以点击这里跳转:站长链接
原文链接:https://blog.csdn.net/qq_41221030/article/details/106711019