文章目录
一、报错信息
参考 【错误记录】git clone 报错 ( fatal: unable to access ‘https…‘:gnutls_handshake() failed: Error in the pu ) 博客 ;
之前是通过切换网络的方式 , 解决了问题 , 这种方式随机性太大 , 继续分析该问题 ;
检查是否能 ping 通 GitHub , 执行
ping github.com
命令 , 执行结果如下 , 丢包率 100% , 无法 ping 通 ;
二、解决方案
参考 Windows 中的解决方案 【错误记录】GitHub 网站和仓库无法访问 ( 域名重定向 | 检查 C:\Windows\System32\drivers\etc\hosts 配置文件中的 GitHub 地址域名配置 ) , 修改 Ubuntu 系统的 /etc/hosts 文件 ;
设置 GitHub 域名 :
140.82.114.4 github.com
151.101.77.194 github.global.ssl.fastly.net
执行
gedit /etc/hosts
命令 , 打开 /etc/hosts 文件 , 将 GitHub 域名添加到文件中 , 完整文件内容为 :
127.0.0.1 localhost
127.0.1.1 octopus
140.82.114.4 github.com
151.101.77.194 github.global.ssl.fastly.net
# 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
保存并关闭 gedit 编辑器 ; ( 此处也可以使用 vim , vi 等文本编辑器 )
再次执行
ping github.com
命令 , 最终 ping 通 GitHub :
root :~/ijkplayer# ping github.com
PING github.com (140.82.114.4) 56(84) bytes of data.
64 bytes from github.com (140.82.114.4): icmp_seq=1 ttl=49 time=279 ms
64 bytes from github.com (140.82.114.4): icmp_seq=2 ttl=49 time=303 ms
64 bytes from github.com (140.82.114.4): icmp_seq=3 ttl=49 time=278 ms
^C
--- github.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 278.916/287.292/303.563/11.515 ms
root :~/ijkplayer#