前言:
最近访问github,总是访问不了,或者是访问慢,甚是烦人,经历了很多次,每次的解决方案都是不同,需要总结为了之后遇到这种情形
基本方法都是 修改 hosts 文件 ,此文件包含 域名 (domain) 和 IP 地址的映射 关系, 众所周知,浏览器是通过解析域名,去访问对应的 IP 地址,返回网页内容的。
This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
This file contains the mappings of IP addresses to host names. Each
entry should be kept on an individual line. The IP address should
be placed in the first column followed by the corresponding host name.
The IP address and the host name should be separated by at least one
方法1
直接添加 一系列 github相关字符串 参考: segmentfault.com/a/119000003…
以 windows 10 为例
hosts 文件在电脑中的路径 : C:\Windows\System32\drivers\etc
打开文件需要管理员权限
在 最下 添加 如下 字符
# GitHub Start
140.82.114.4 github.com
140.82.114.4 gist.github.com
185.199.108.153 assets-cdn.github.com
151.101.64.133 raw.githubusercontent.com
151.101.108.133 gist.githubusercontent.com
151.101.108.133 cloud.githubusercontent.com
151.101.108.133 camo.githubusercontent.com
151.101.108.133 avatars0.githubusercontent.com
151.101.108.133 avatars1.githubusercontent.com
151.101.108.133 avatars2.githubusercontent.com
151.101.108.133 avatars3.githubusercontent.com
151.101.108.133 avatars4.githubusercontent.com
151.101.108.133 avatars5.githubusercontent.com
151.101.108.133 avatars6.githubusercontent.com
151.101.108.133 avatars7.githubusercontent.com
151.101.108.133 avatars8.githubusercontent.com
# GitHub End