Skip to content

跨平台Hosts修改指南:解决GitHub网络访问故障

一、技术原理

graph LR
A[DNS污染/劫持] --> B[域名解析失败]
B --> C[手动绑定IP与域名]
C --> D[强制指定访问路径]

二、操作流程

1. 获取最新IP地址

权威查询平台

目标域名清单

bash
# 核心服务节点
github.com
global-ssl.fastly.net

# 扩展服务节点(可选)
api.github.com
codeload.github.com

2. 多平台Hosts修改方案

| 操作系统 | 文件路径 | 权限要求 | |---------|---------|---------|---------| | Windows | C:\Windows\System32\drivers\etc\hosts | 管理员权限 | | macOS | /private/etc/hosts | sudo权限 | | Linux | /etc/hosts | root权限 |

配置模板

txt
# GitHub核心服务(2024.01验证)
140.82.112.3    github.com
199.232.69.194  global-ssl.fastly.net

# GitHub子服务(可选配置)
185.199.108.153 assets-cdn.github.com

3. 验证配置

bash
# Windows
ipconfig /flushdns

# macOS/Linux
sudo dscacheutil -flushcache

然后访问 https://github.com 验证连接是否正常。