Could not resolve host: github.com的解决方案

描述:
新装的ubuntu2004,git clone命令时遇到标题描述问题。
发现可以上网,但是ping github.com会出错
解决方法:
第一步、
1、打开hosts文件

sudo vim /etc/hosts

2、在添加github.com域名(localhost下添加即可)

140.82.114.4    github.com

3、现在尝试ping github.com发现可以ping通
就可以了,不行换个域名,域名查找网站可以去知乎搜一下

第二步、可以使用git clone了,但是会发现很慢,解决方法
把com换成zygxsq.cn
比如

git clone https://github.com/verilator/verilator

换成

https://github.zygxsq.cn/verilator/verilator

版权声明:本文为yjn18021006815原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。