mac终端ping github.com 失败解决

今天在brew update 操作时一直失败


 
 
  1. 192:develops admin$ brew update
  2. fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': transfer closed with outstanding read data remaining
  3. Error: Fetching /usr/ local/Homebrew/ Library/Taps/homebrew/homebrew-core failed!
  4. 192:develops admin$ brew update
  5. fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
  6. Error: Fetching /usr/ local/Homebrew/ Library/Taps/homebrew/homebrew-core failed!
  7. 192:develops admin$ ping github.com
  8. PING github.com ( 52.74 .223 .119): 56 data bytes
  9. Request timeout for icmp_seq 0
  10. Request timeout for icmp_seq 1
  11. Request timeout for icmp_seq 2
  12. Request timeout for icmp_seq 3
  13. Request timeout for icmp_seq 4
  14. Request timeout for icmp_seq 5
  15. ^C
  16. --- github.com ping statistics ---
  17. 7 packets transmitted, 0 packets received, 100.0% packet loss

然后我就ping了下github.com 从上可以看出一直时超时丢包率100%

多亏网上大佬的解决方案:原网页链接

大家都去给他点赞加流量吧,我就是自己理解然后翻译记录下以防万一虽说是原创但是点子不是...

毕竟不是我原创

这个问题的原因是网络问题:

解决的方法:

 修改hosts文件的内容

终端执行:(我自己发现两个一样)

sudo vim /etc/hosts
 
 
sudo vim /private/etc/hosts
 
 

上边的两个命令执行一个就行.效果一样的. 都会让你输入密码然后才能修改

然后把下边的ip和域名的映射加进去


 
 
  1. 151 .101 .185 .194 github .global .ssl .fastly .net
  2. 192 .30 .253 .112 github .com
  3. 151 .101 .184 .133 assets-cdn .github .com
  4. 151 .101 .184 .133 avatars0 .githubusercontent .com
  5. 151 .101 .112 .133 avatars1 .githubusercontent .com

退出保存.

保险起见可以在打看看修改的效果

sudo cat /etc/hosts
 
 

确认修改后再次ping github


 
 
  1. 192:develops admin$ ping github.com
  2. PING github.com ( 192.30 .253 .112): 56 data bytes
  3. 64 bytes from 192.30 .253 .112: icmp_seq= 0 ttl= 48 time= 239.154 ms
  4. 64 bytes from 192.30 .253 .112: icmp_seq= 1 ttl= 48 time= 363.124 ms
  5. 64 bytes from 192.30 .253 .112: icmp_seq= 2 ttl= 48 time= 280.951 ms
  6. 64 bytes from 192.30 .253 .112: icmp_seq= 3 ttl= 48 time= 223.892 ms
  7. 64 bytes from 192.30 .253 .112: icmp_seq= 4 ttl= 48 time= 221.176 ms
  8. 64 bytes from 192.30 .253 .112: icmp_seq= 5 ttl= 48 time= 221.025 ms
  9. 64 bytes from 192.30 .253 .112: icmp_seq= 6 ttl= 48 time= 221.304 ms
  10. 64 bytes from 192.30 .253 .112: icmp_seq= 7 ttl= 48 time= 226.958 ms
  11. 64 bytes from 192.30 .253 .112: icmp_seq= 8 ttl= 48 time= 314.070 ms
  12. ^C
  13. --- github.com ping statistics ---
  14. 9 packets transmitted, 9 packets received, 0.0% packet loss
  15. round-trip min/avg/max/stddev = 221.025/ 256.850/ 363.124/ 48.605 ms

就可以看到9个包传输接收到9个,0.0%的丢包率 . 大功告成

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值