Skip to content

自动更新 hosts 文件的 IP 地址,缓解中国大陆访问 GitHub 时遇到的网络问题

License

Notifications You must be signed in to change notification settings

ittuann/GitHub-IP-hosts

Repository files navigation

📄 GitHub IP hosts

GitHub Action

通过使用 GitHub Actions 每周自动更新 hosts 文件,解决中国大陆访问 GitHub 时遇到的抽风问题,诸如访问缓慢、图片加载失败等等。

目录

Tip

Star 🌟 这个仓库,您将能在第一时间收到所有的更新和动态~

🛠️ 使用方法

使用方法仅需 2 步: 复制 hosts 文本 -> 将复制的文本粘贴至系统 hosts 文件

1. 复制下面的 hosts 内容

# GitHub IP hosts Start
# Auto update time: 2024-11-11 10:42:42 UTC+08:00
# IP 可能会随时变化,请关注 GitHub 项目仓库,以获取最新数据
# GitHub URL: https://github.com/ittuann/GitHub-IP-hosts
# Update URL: https://raw.githubusercontent.com/ittuann/GitHub-IP-hosts/main/hosts

140.82.112.25   alive.github.com
140.82.114.25   alive.github.com
140.82.114.5    api.github.com
140.82.114.6    api.github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
185.199.108.133 avatars.githubusercontent.com
185.199.109.133 avatars.githubusercontent.com
185.199.110.133 avatars.githubusercontent.com
185.199.111.133 avatars.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.109.133 avatars0.githubusercontent.com
185.199.110.133 avatars0.githubusercontent.com
185.199.111.133 avatars0.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.109.133 avatars1.githubusercontent.com
185.199.110.133 avatars1.githubusercontent.com
185.199.111.133 avatars1.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
185.199.110.133 avatars2.githubusercontent.com
185.199.111.133 avatars2.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.109.133 avatars3.githubusercontent.com
185.199.110.133 avatars3.githubusercontent.com
185.199.111.133 avatars3.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.109.133 avatars4.githubusercontent.com
185.199.110.133 avatars4.githubusercontent.com
185.199.111.133 avatars4.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.109.133 avatars5.githubusercontent.com
185.199.110.133 avatars5.githubusercontent.com
185.199.111.133 avatars5.githubusercontent.com
185.199.108.133 camo.githubusercontent.com
185.199.109.133 camo.githubusercontent.com
185.199.110.133 camo.githubusercontent.com
185.199.111.133 camo.githubusercontent.com
140.82.112.22   central.github.com
140.82.113.22   central.github.com
185.199.108.133 cloud.githubusercontent.com
185.199.109.133 cloud.githubusercontent.com
185.199.110.133 cloud.githubusercontent.com
185.199.111.133 cloud.githubusercontent.com
140.82.113.9    codeload.github.com
140.82.114.10   codeload.github.com
140.82.112.21   collector.github.com
140.82.112.22   collector.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.109.133 desktop.githubusercontent.com
185.199.110.133 desktop.githubusercontent.com
185.199.111.133 desktop.githubusercontent.com
140.82.112.21   education.github.com
140.82.114.22   education.github.com
185.199.108.133 favicons.githubusercontent.com
185.199.109.133 favicons.githubusercontent.com
185.199.110.133 favicons.githubusercontent.com
185.199.111.133 favicons.githubusercontent.com
140.82.113.3    gist.github.com
140.82.114.4    gist.github.com
16.15.176.65    github-cloud.s3.amazonaws.com
16.182.71.89    github-cloud.s3.amazonaws.com
3.5.12.218      github-cloud.s3.amazonaws.com
3.5.25.59       github-cloud.s3.amazonaws.com
16.15.192.14    github-com.s3.amazonaws.com
16.182.104.121  github-com.s3.amazonaws.com
3.5.19.21       github-com.s3.amazonaws.com
3.5.20.23       github-com.s3.amazonaws.com
192.0.66.2      github.blog
140.82.112.4    github.com
140.82.113.4    github.com
140.82.112.18   github.community
185.199.108.154 github.githubassets.com
185.199.109.154 github.githubassets.com
185.199.110.154 github.githubassets.com
185.199.111.154 github.githubassets.com
151.101.1.194   github.global.ssl.fastly.net
151.101.129.194 github.global.ssl.fastly.net
151.101.193.194 github.global.ssl.fastly.net
151.101.65.194  github.global.ssl.fastly.net
185.199.108.153 github.io
185.199.109.153 github.io
185.199.110.153 github.io
185.199.111.153 github.io
185.199.108.133 github.map.fastly.net
185.199.109.133 github.map.fastly.net
185.199.110.133 github.map.fastly.net
185.199.111.133 github.map.fastly.net
185.199.108.153 githubstatus.com
185.199.109.153 githubstatus.com
185.199.110.153 githubstatus.com
185.199.111.153 githubstatus.com
140.82.112.26   live.github.com
140.82.114.25   live.github.com
185.199.108.133 media.githubusercontent.com
185.199.109.133 media.githubusercontent.com
185.199.110.133 media.githubusercontent.com
185.199.111.133 media.githubusercontent.com
185.199.108.133 objects.githubusercontent.com
185.199.109.133 objects.githubusercontent.com
185.199.110.133 objects.githubusercontent.com
185.199.111.133 objects.githubusercontent.com
13.107.42.16    pipelines.actions.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
185.199.110.133 user-images.githubusercontent.com
185.199.111.133 user-images.githubusercontent.com

# GitHub IP hosts End

2. 将内容粘贴到系统 hosts 文件中

Windows 系统粘贴方法

  1. 在搜索框中输入记事本,右键选择以管理员身份运行打开记事本。
  2. 在记事本中依次点击文件 -> 打开
  3. 将弹出框右下角的文件类型从文本文档(*.txt)改为所有文件(*.*)
  4. 前往路径: C:\Windows\System32\drivers\etc,然后选择hosts文件即可开始编辑
  5. 将复制的内容直接粘贴到文件末尾,保存即可

大部分情况下无需手动刷新 DNS,如未生效可在 CMD / PowerShell 中执行ipconfig /flushdns

Linux 系统粘贴方法

在终端中执行 sudoedit /etc/hosts,然后将复制的内容直接粘贴到文件末尾,保存即可。

🔭 进阶使用

  1. 项目默认支持返回所有响应中速度最快的 IP 地址。
  2. 使用只记录单一 IP 的 hosts 文件: 复制项目内的 hosts_single 文件内容即可。
  3. 在本地/海外服务器自部署项目: 在项目根目录使用终端执行 make 命令即可。
  4. 使用 jsDelivr CDN 加速下载 hosts & hosts_single 文件:
    • https://cdn.jsdelivr.net/gh/ittuann/GitHub-IP-hosts@main/hosts
    • https://fastly.jsdelivr.net/gh/ittuann/GitHub-IP-hosts@main/hosts
    • https://testingcf.jsdelivr.net/gh/ittuann/GitHub-IP-hosts@main/hosts
    • https://gcore.jsdelivr.net/gh/ittuann/GitHub-IP-hosts@main/hosts
  5. 通过 SwitchHosts 工具自动更新 hosts 文件。
  6. 完整的 workflows 工作流请参考 GitHub Actions 的 CI/CD 配置。

About

自动更新 hosts 文件的 IP 地址,缓解中国大陆访问 GitHub 时遇到的网络问题

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published