本文共 1550 字,大约阅读时间需要 5 分钟。
要解决访问GitHub的问题,可以通过修改hosts文件来实现。以下是详细的操作步骤:
打开Windows的hosts文件。通常,hosts文件位于C:\Windows\system32\drivers\etc\目录下。
在文本编辑器中打开hosts文件,找到文件末尾的空行。
添加以下记录:
140.82.113.3 github.com140.82.114.20 gist.github.com151.101.184.133 assets-cdn.github.com151.101.184.133 raw.githubusercontent.com151.101.184.133 gist.githubusercontent.com151.101.184.133 cloud.githubusercontent.com151.101.184.133 camo.githubusercontent.com199.232.68.133 avatars0.githubusercontent.com199.232.28.133 avatars0.githubusercontent.com151.101.184.133 avatars1.githubusercontent.com199.232.68.133 avatars3.githubusercontent.com199.232.28.133 avatars2.githubusercontent.com
保存并关闭编辑器。
重新启动网络服务。打开命令提示符,输入以下命令:
ipconfig /flushdns
或者
net reset -s
在Ubuntu系统中,可以通过命令行工具完成相关配置:
打开终端,执行nslookup命令验证GitHub域名解析是否正常:
nslookup github.com
如果解析结果显示IP地址不正确,继续执行下一步。
打开hosts文件,地址为/etc/hosts
,使用文本编辑器(如gedit)打开:
sudo gedit /etc/hosts
在文件末尾添加以下记录:
# GitHub Start140.82.113.3 github.com140.82.114.20 gist.github.com151.101.184.133 assets-cdn.github.com151.101.184.133 raw.githubusercontent.com151.101.184.133 gist.githubusercontent.com151.101.184.133 cloud.githubusercontent.com151.101.184.133 camo.githubusercontent.com199.232.68.133 avatars0.githubusercontent.com199.232.28.133 avatars0.githubusercontent.com151.101.184.133 avatars1.githubusercontent.com199.232.68.133 avatars3.githubusercontent.com199.232.28.133 avatars2.githubusercontent.com# GitHub End
保存并退出编辑器。
重新启动网络服务:
sudo /etc/init.d/networking restart
通过以上步骤,可以实现对GitHub域名的本地解析,解决访问速度缓慢或域名解析不正确的问题。
转载地址:http://wrrfk.baihongyu.com/