一、工具介绍
Fetch GitHub Hosts是一款开源跨平台的国内GitHub加速访问工具,主要为解决研究及学习人员访问 Github 过慢或其他问题而提供的 Github Hosts 同步工具。
项目原理:是通过部署此项目本身的服务器来获取 github.com 的 hosts,而不是通过第三方ip地址接口来进行获取,例如 ipaddress.com 等。
二、使用方法
图形化界面
软件支持图像化界面操作,不用直接操作hosts,对小白也非常友好且方便
下载完成解压压缩包,运行对应平台的执行文件即可运行(⚠️注意:Linux下需要用进行启动,Windows和MacOS会自动进行提权操作。)
客户端模式

客户端启动

客户端主机源选择

客户端主机源自定义

服务端模式

三、命令行终端
参数
| 参数名 | 缩写 | 默认值 | 必填 | 描述 | 
|---|---|---|---|---|
| mode | m | 无 | 是 | 启动模式 server(服务端)/client(客户端) | 
| interval | i | 60 | 否 | 获取记录值间隔(分钟) | 
| port | p | 9898 | 否 | 服务模式监听端口以访问HTTP服务 | 
| url | u | https://hosts.gitcdn.top/hosts.txt | 否 | 客户端模式远程主机获取链接 | 
启动客户端
注意:
Linux下需要使用运行;
sudoWindows和MacOS会自动进行提权操作。
- 直接运行
# Linux/Macos
sudo fetch-github-hosts -m=client# Windows
fetch-github-hosts.exe -m=client- 自定义获取时间间隔
# Linux/Macos(10分钟获取一次)
sudo fetch-github-hosts -i=10# Windows(10分钟获取一次)
fetch-github-hosts.exe -i=10- 自定义获取链接
# Linux/Macos
sudo fetch-github-hosts -u=http://127.0.0.1:9898/hosts.json# Windows
fetch-github-hosts.exe -u=http://127.0.0.1:9898/hosts.json启动服务端
- 直接运行
# Linux/Macos
fetch-github-hosts -m=server# Windows
fetch-github-hosts.exe -m=server- 自定义监听端口
# Linux/Macos
fetch-github-hosts -m=server -p=6666# Windows
fetch-github-hosts.exe -m=server -p=6666手动
添加主机
将以下全部内容粘贴到你的hosts文件中,即可。
# fetch-github-hosts begin
140.82.112.26               alive.github.com
140.82.114.25               live.github.com
185.199.111.154             github.githubassets.com
140.82.113.21               central.github.com
185.199.110.133             desktop.githubusercontent.com
2606:50c0:8001::153         assets-cdn.github.com
185.199.111.133             camo.githubusercontent.com
185.199.108.133             github.map.fastly.net
151.101.161.194             github.global.ssl.fastly.net
140.82.114.3                gist.github.com
185.199.110.153             github.io
140.82.113.3                github.com
192.0.66.2                  github.blog
140.82.114.5                api.github.com
2606:50c0:8003::154         raw.githubusercontent.com
2606:50c0:8002::154         user-images.githubusercontent.com
185.199.110.133             favicons.githubusercontent.com
185.199.109.133             avatars5.githubusercontent.com
185.199.108.133             avatars4.githubusercontent.com
185.199.110.133             avatars3.githubusercontent.com
185.199.111.133             avatars2.githubusercontent.com
185.199.109.133             avatars1.githubusercontent.com
185.199.111.133             avatars0.githubusercontent.com
2606:50c0:8000::154         avatars.githubusercontent.com
140.82.112.9                codeload.github.com
54.231.171.201              github-cloud.s3.amazonaws.com
3.5.8.134                   github-com.s3.amazonaws.com
52.217.40.244               github-production-release-asset-2e65be.s3.amazonaws.com
52.217.9.60                 github-production-user-asset-6210df.s3.amazonaws.com
52.217.160.97               github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.109.153             githubstatus.com
140.82.114.18               github.community
52.224.38.193               github.dev
140.82.112.22               collector.github.com
2620:1ec:21::16             pipelines.actions.githubusercontent.com
2606:50c0:8000::154         media.githubusercontent.com
185.199.110.133             cloud.githubusercontent.com
185.199.110.133             objects.githubusercontent.com
# last fetch time: 2023-08-03 10:42:51
# update url: https://hosts.gitcdn.top/hosts.txt
# fetch-github-hosts end- Linux / MacOShosts路径:- /etc/hosts
- Windowshosts路径:- C:\Windows\System32\drivers\etc\hosts
刷新生效
- Linux:- /etc/init.d/network restart
- Windows:- ipconfig /flushdns
- Macos:- sudo killall -HUP mDNSResponder
Unix/Linux一键使用
sed -i "/# fetch-github-hosts begin/Q" /etc/hosts && curl https://hosts.gitcdn.top/hosts.txt >> /etc/hosts提示:可以设置crontab定时任务定时获取更新即可,解放双手!
四、私有部署
略
五、国内GitHub加速访问工具GitHub地址
地址:点击前往下载