Windows10

通过nslookup命令获取GitHub域名服务器地址,然后ping该地址

nslookup github.com
ping 域名服务器地址

nslookup.png

发现20.205.243.166能稳定ping通,但是浏览器却打不开


接着使用管理员身份运行notepad++,然后打开文件C:\Windows\System32\drivers\etc\hosts,在最后一行加上以下代码

域名服务器地址 github.com

hosts.png

注意域名服务器地址经常会改变,不一定要按照教程的地址来,然后保存,关闭文件


这时关闭浏览器,重新打开浏览器再输入github.com,就能正常打开了

github.png

Ubuntu20.04

跟Windows一样,Linux也有nslookup命令

nslookup github.com

更新文件/etc/hosts20.205.243.166为此时github主机ip

127.0.0.1	localhost
127.0.1.1	ubuntu
20.205.243.166  github.com

# 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

这样可以访问GitHub了