赞
踩
hosts 文件在每个系统的位置不一,详情如下:
Windows 系统:C:\Windows\System32\drivers\etc\hosts
Linux 系统:/etc/hosts
Mac(苹果电脑)系统:/etc/hosts
Android(安卓)系统:/system/etc/hosts
iPhone(iOS)系统:/etc/hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
140.82.113.3 github.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.1.194 github.global.ssl.fastly.net
151.101.65.194 github.global.ssl.fastly.net
151.101.129.194 github.global.ssl.fastly.net
151.101.193.194 github.global.ssl.fastly.net
在末尾添加三行记录并保存。(需管理员权限,注意IP地址与域名间需留有空格)其实就是为域名添加 IP 映射。
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 140.82.113.3 github.com 140.82.113.3 gist.github.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.1.194 github.global.ssl.fastly.net 151.101.65.194 github.global.ssl.fastly.net 151.101.129.194 github.global.ssl.fastly.net 151.101.193.194 github.global.ssl.fastly.net 185.199.108.133 raw.githubusercontent.com 185.199.108.133 gist.githubusercontent.com 185.199.108.133 cloud.githubusercontent.com 185.199.108.133 camo.githubusercontent.com 185.199.108.133 avatars0.githubusercontent.com 185.199.108.133 avatars1.githubusercontent.com 185.199.108.133 avatars2.githubusercontent.com 185.199.108.133 avatars3.githubusercontent.com 185.199.108.133 avatars4.githubusercontent.com 185.199.108.133 avatars5.githubusercontent.com 185.199.108.133 avatars6.githubusercontent.com 185.199.108.133 avatars7.githubusercontent.com 185.199.108.133 avatars8.githubusercontent.com
ipconfig /flushdns
刷新缓存再打开github参考解决github有时能访问有时不能访问的问题
在github能打开时,打开电脑的cmd,查看域名
ipconfig/flushdns
nslookup github.com
然后在hosts文件末尾添加一行20.205.243.166 github.com
即可
win+R搜cmd里查域名
添加到hosts最后一句,路径C:\Windows\System32\drivers\etc\hosts
同样也是,改不了的话先把hosts挪到桌面上,改完保存好在挪回去
OK到这里还不成功,还打不开
在cmd刷新一下缓存
OK还是不行
在hosts结尾里添加这几句后关闭浏览器再打开即可
# GitHub IP地址
140.82.121.4 github.com
185.199.108.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.110.133 objects.githubusercontent.com
185.199.111.133 objects.githubusercontent.com
185.199.108.133 objects.githubusercontent.com
185.199.109.133 objects.githubusercontent.com
185.199.111.154 github.githubassets.com
185.199.108.154 github.githubassets.com
185.199.109.154 github.githubassets.com
185.199.110.154 github.githubassets.com
最终hosts内容,这部分复制的在上文添加的之前
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。