GitHub经常打不开,或者打开特别慢,一种解决方案是 找到官网IP地址、CDN域名IP地址、静态资源IP地址,然后配置本机hosts文件,刷新DNS缓存即可。
fastly.net.ipaddress.com: https://fastly.net.ipaddress.com/github.global.ssl.fastly.net
assets-cdn.github.com: https://github.com.ipaddress.com/assets-cdn.github.com
MacOS或Linux环境hosts文件路径/etc/hosts
; Windows环境是C:\Windows\System32\drivers\etc
。
以下是在MacOS或Linux环境下:
% sudo cat <<EOF>>/etc/hosts
# github.com
140.82.113.3 github.com
199.232.69.194 github.global.ssl.fastly.net
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
EOF
% ipconfig /flushdns # in windows
% sudo systemctl restart network-manager # in Linux that use systemd as init
% sudo killall -HUP mDNSResponder # in MacOS
注意:如果使用了dnsmasq作为本地代理DNS服务器,还需要重启dnsmasq服务:
% sudo systemctl restart dnsmasq # in Linux that use systemd as init
% sudo brew services restart dnsmasq # in MacOS
后记:亲测,不是特别有用,时灵时不灵,关键是GitHub资源拉取受阻不一定是DNS污染所致,可能是对应的IP地址访问受阻,这就有点蛋疼了 :(