GitHub加速——亲测有效

方法一:修改hosts文件

DNS的解析过程在文章——什么是DNS?——DNS和域名解析详解 中已经介绍过了。简单来说,如果我们的电脑上已经有了GitHub的 IP-域名 映射关系,那么就不会去请求本地域名解析服务了。这样我们就需要保证hosts文件里面的 IP-域名 映射关系是有效的了。那么哪里有这样的IP-域名映射清单呢?不要慌,办法总比困难多,总有人先你一步踩过类似的坑。所以我们可以去国内的代码托管平台上看看

我们在Gitee上找到了一个项目,其中就有GitHub的IP-域名映射清单:https://gitee.com/klmahuaw/GitHub520然后,我们将下面的内容复制到hosts文件下即可:

GitHub520 Host Start

140.82.114.25 alive.github.com
140.82.113.5 api.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.133 avatars.githubusercontent.com
185.199.111.133 avatars0.githubusercontent.com
185.199.111.133 avatars1.githubusercontent.com
185.199.111.133 avatars2.githubusercontent.com
185.199.111.133 avatars3.githubusercontent.com
185.199.111.133 avatars4.githubusercontent.com
185.199.111.133 avatars5.githubusercontent.com
185.199.111.133 camo.githubusercontent.com
140.82.112.22 central.github.com
185.199.111.133 cloud.githubusercontent.com
140.82.114.9 codeload.github.com
140.82.113.22 collector.github.com
185.199.111.133 desktop.githubusercontent.com
185.199.111.133 favicons.githubusercontent.com
140.82.112.3 gist.github.com
52.216.163.147 github-cloud.s3.amazonaws.com
52.217.124.1 github-com.s3.amazonaws.com
52.216.144.83 github-production-release-asset-2e65be.s3.amazonaws.com
52.217.121.249 github-production-repository-file-5c1aeb.s3.amazonaws.com
52.217.206.57 github-production-user-asset-6210df.s3.amazonaws.com
192.0.66.2 github.blog
140.82.114.4 github.com
140.82.113.18 github.community
185.199.110.154 github.githubassets.com
151.101.1.194 github.global.ssl.fastly.net
185.199.110.153 github.io
185.199.111.133 github.map.fastly.net
185.199.110.153 githubstatus.com
140.82.112.25 live.github.com
185.199.111.133 media.githubusercontent.com
185.199.111.133 objects.githubusercontent.com
13.107.42.16 pipelines.actions.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.111.133 user-images.githubusercontent.com
13.107.253.40 vscode.dev
140.82.112.21 education.github.com

Update time: 2023-08-01T14:06:06+08:00

Update url: https://raw.hellogithub.com/hosts

Star me: https://github.com/521xueweihan/GitHub520

GitHub520 Host End

顺便说明一下,Windows系统的hosts文件路径是 C:\Windows\System32\drivers\etc\hosts ,而linux系统的hosts文件路径则是 /etc/hosts 。我们在编辑和保存hosts文件都需要管理员权限(Linux系统是root权限)。项目里面也有具体说明应该如何操作,按照指引操作准没问题。

缺点:hosts文件里面的映射关系随时有可能失效,失效后需要重新修改hosts文件,设置正确的 ip-域名 映射关系。
方法二:安装代理服务软件

代理服务软件的工作原理也是类似,即先将请求转发到本地的代理服务软件对应的端口,然后由代理服务将请求转发到GitHub上。
这里我们也找到了一个免费的代理服务软件——Watt Toolkit。这是一个免费开源跨平台的代理服务软件,官网地址:https://steampp.net
之前去官网上下载安装即可,Windows版本和Linux版本都有。Gitee地址https://gitee.com/rmbgame/SteamTools,项目里面也都有详细的文档介绍。
(PS:这里没有贴上GitHub地址是因为,我们假设的前提是,GitHub都访问不了,贴上GitHub地址自然就没有意义了)
缺点:代理服务软件的代理服务可能失效,或者代理服务软件需要按月付费。

代理服务失效的问题我们也亲自踩过坑了,要解决这个问题,我们就只能转战方法一了。这里就需要我们去检查一下hosts文件,因为软件会将github相关的域名全部映射到本地。
总结

GitHub访问不了,一般是代理服务器的问题。这时我们需要绕过代理服务器,通过配置本地hosts的 IP-域名 映射,或者安装代理软件来解决。配置本地hosts文件时,相应的 IP-域名 映射可能会失效,失效时需要重新更新。使用代理软件时,代理软件可能会失效或者需要付费。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值