前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【错误记录】Ubuntu 修改 hosts 文件 ( 使用 gedit /etc/hosts 命令打开并修改 hosts 文件 )

【错误记录】Ubuntu 修改 hosts 文件 ( 使用 gedit /etc/hosts 命令打开并修改 hosts 文件 )

作者头像
韩曙亮
发布2023-03-30 13:17:31
3K0
发布2023-03-30 13:17:31
举报
文章被收录于专栏:韩曙亮的移动开发专栏

文章目录

一、报错信息


参考 【错误记录】git clone 报错 ( fatal: unable to access ‘https…‘:gnutls_handshake() failed: Error in the pu ) 博客 ;

之前是通过切换网络的方式 , 解决了问题 , 这种方式随机性太大 , 继续分析该问题 ;

检查是否能 ping 通 GitHub , 执行

代码语言:javascript
复制
ping github.com

命令 , 执行结果如下 , 丢包率 100% , 无法 ping 通 ;

二、解决方案


参考 Windows 中的解决方案 【错误记录】GitHub 网站和仓库无法访问 ( 域名重定向 | 检查 C:\Windows\System32\drivers\etc\hosts 配置文件中的 GitHub 地址域名配置 ) , 修改 Ubuntu 系统的 /etc/hosts 文件 ;

设置 GitHub 域名 :

代码语言:javascript
复制
140.82.114.4 github.com
151.101.77.194 github.global.ssl.fastly.net

执行

代码语言:javascript
复制
gedit /etc/hosts

命令 , 打开 /etc/hosts 文件 , 将 GitHub 域名添加到文件中 , 完整文件内容为 :

代码语言:javascript
复制
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 等文本编辑器 )

再次执行

代码语言:javascript
复制
ping github.com

命令 , 最终 ping 通 GitHub :

代码语言:javascript
复制
root@octopus:~/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@octopus:~/ijkplayer# 
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-03-19,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 一、报错信息
  • 二、解决方案
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档