Skip to content

GitHub中国加速访问 #3

Open
@chenxuhua

Description

@chenxuhua
Owner

GitHub中国加速访问

问:为什么访问速度会很慢

答:GitHub的CDN域名遭到DNS污染

GitHub在中国大陆访问速度慢的问题原因有很多,但最直接和最主要的原因是GitHub的分发加速网络的域名遭到DNS污染。

由于GitHub的加速分发CDN域名assets-cdn.github.com遭到DNS污染,导致无法连接使用GitHub的加速分发服务器,才使得中国大陆访问速度很慢。

问:如何解决DNS污染

答:通过修改Hosts解决污染问题

一般的DNS问题都可以通过修改Hosts文件来解决,GitHub的CDN域名被污染问题也不例外,同样可以通过修改Hosts文件解决。

将域名解析直接指向IP地址来绕过DNS的解析,以此解决污染问题。

问:如何修改Hosts文件

答:请按以下步骤操作

①获取被污染域名的实际IP地址

访问IPAddress.com使用IP Lookup工具获得这个域名的IP地址。

或者是访问http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo查询域名的IP地址。

笔者撰写此文时,得出该域名IP地址为:151.101.100.133

②修改系统的Hosts文件

打开在Hosts文件,在文件尾部插入新行,添加以下代码并保存

151.101.100.133 assets-cdn.github.com

至此,GitHub的加速优化基本完成,只需等待本机的DNS缓存刷新生效,即可享受高速的GitHub访问。

Activity

ghost

ghost commented on Nov 22, 2016

@ghost

你这个IP延迟300ms+,这样没起到加速作用,反而还会减速。

我找了下,151.101.76.249这个IP最好,我这里ping值是20ms+

archonwang

archonwang commented on Nov 25, 2016

@archonwang

我这个得到的是 151.101.36.249这个ip

chenxuhua

chenxuhua commented on Nov 30, 2016

@chenxuhua
OwnerAuthor

抱歉,此文因长期为更新导致IP地址失效。
如需加速GitHub访问,请将下列Hosts加入系统:

# GitHub Start
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.com
# GitHub End
chilly

chilly commented on Oct 12, 2017

@chilly

依旧很慢。特别是git clone. 不过把你那些ip地址用IPAdress的替换后倒是快了不少。

corningsun

corningsun commented on Jul 11, 2018

@corningsun

20180711 update ip from https://www.ipaddress.com/

# GitHub Start
192.30.253.112 github.com
192.30.253.118 gist.github.com
151.101.112.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.112.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.112.133 camo.githubusercontent.com
151.101.112.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.12.133 avatars3.githubusercontent.com
151.101.12.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.12.133 avatars8.githubusercontent.com
# GitHub End
ximply

ximply commented on Jul 24, 2018

@ximply

1.1.1.1

Swifree

Swifree commented on Jul 31, 2018

@Swifree

推荐一个简单高效的方式:直接把dns服务器修改为8.8.4.4(google开放dns服务器),ipaddress查询的不知道依赖的哪个dns服务器,感觉也是被污染的

k0aaa

k0aaa commented on Aug 10, 2018

@k0aaa

@Swifree DNS协议被污染的,光改服务器没用

jesse7866

jesse7866 commented on Nov 19, 2018

@jesse7866

20180711 update ip from https://www.ipaddress.com/

# GitHub Start
192.30.253.112 github.com
192.30.253.118 gist.github.com
151.101.112.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.112.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.112.133 camo.githubusercontent.com
151.101.112.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.12.133 avatars3.githubusercontent.com
151.101.12.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.12.133 avatars8.githubusercontent.com
# GitHub End

这个有效!从10KB直接飙到500KB

ghost

ghost commented on Dec 14, 2018

@ghost

@chenxuhua gibhub有哪些子域名是如何查的呢?

RickySyr

RickySyr commented on Jan 30, 2019

@RickySyr

可以写个脚本,自动更新host文件

ptsa

ptsa commented on Mar 9, 2019

@ptsa

可以写个脚本,自动更新host文件

有现成的脚本么

dbarobin

dbarobin commented on Mar 17, 2019

@dbarobin

@ptsa 我写了一个,https://github.com/dbarobin/github,此外我的文章有更多的加速方法,点击 此处 阅读。

dbarobin

dbarobin commented on May 23, 2019

@dbarobin

@ptsa 我写了一个,https://github.com/dbarobin/github,此外我的文章有更多的加速方法,点击 此处 阅读。

你的脚本是不是有些问题啊?

Python 2.7

1269976077

1269976077 commented on Jun 12, 2019

@1269976077

googlehosts/hosts: 镜像:https://coding.net/u/scaffrey/p/hosts/git
https://github.com/googlehosts/hosts
这个hosts更新好像挺勤快的,同时还有别的host问题的解决,比如onedirve

1 remaining item

kid1412621

kid1412621 commented on Jul 25, 2019

@kid1412621

52.216.96.115 github-production-release-asset-2e65be.s3.amazonaws.com
感觉提升也不明显呢?

yunshao

yunshao commented on Aug 13, 2019

@yunshao

修改了hosts文件,刷新了DNS,git clone速度没有提升?

wittwitt

wittwitt commented on Aug 22, 2019

@wittwitt

52.216.96.115 github-production-release-asset-2e65be.s3.amazonaws.com
感觉提升也不明显呢?

amazonaws.com,很多不可以的,要翻墙,这种方法应该不行

InCodingNowLiu

InCodingNowLiu commented on Oct 18, 2019

@InCodingNowLiu

有哪位知道微信mac电脑端的图片域名是多少么

tenadolanter

tenadolanter commented on Mar 5, 2020

@tenadolanter

我的是这样,确实快很多,地方不同可能ip不一样,自己可以去https://www.ipaddress.com/ip-lookup查一下

140.82.113.3 github.com
192.30.253.118 gist.github.com
185.199.109.153 assets-cdn.github.com
199.232.68.133 raw.githubusercontent.com
199.232.68.133  gist.githubusercontent.com
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 avatars4.githubusercontent.com
199.232.28.133 avatars5.githubusercontent.com
199.232.28.133 avatars6.githubusercontent.com
199.232.28.133 avatars7.githubusercontent.com
199.232.28.133 avatars8.githubusercontent.com
jawil

jawil commented on May 7, 2020

@jawil

这个根本没啥用,搭个梯子,配置一下域名代理,基本就 OK 了。

image

.github.com
||github.com
github.global.ssl.fastly.net
.githubassets.com
||githubassets.com
.githubusercontent.com
||githubusercontent.com

打开速度飞快

image

没用代理之前,慢到令人发指:

image

git clone 的时候也要配置一下 socket5 代理,速度也是提升很多。

git clone 代理设置

首先确保梯子可正常使用,软件建议使用 v2ray。

https访问
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

其中1080是 socks5 的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1080.

设置完成后, ~/.gitconfig 文件中会增加以下条目:

[http "https://github.com"]  proxy = socks5://127.0.0.1:1080

如果不想用梯子正常访问,可以考虑取消代理设置

git config --global --unset http.https://github.com.proxy
ssh访问

需要修改 ~/.ssh/config 文件, 没有的话新建一个. 同样仅为github.com设置代理:

Host github.com  User git  ProxyCommand nc -v -x 127.0.0.1:1080 %h %p

配置代理前后速度对比图

image

同理 homebrew 这种代理方式也适用,用 brew 下载速度飞起。

ZZYhho

ZZYhho commented on Jun 29, 2020

@ZZYhho

我也找加速git方法好久了,去DNS污染也就到几K十几K,最好的方式还是加代理,不过配起来麻烦,推荐下面这种方式转链,加个前缀效果杠杠的
https://github.com/hunshcn/gh-proxy
码云的官方克隆搬运也还行,不过也有一下缺点:

  1. 对于releases包就不行了,只是源码
  2. 搬运资源有限要不自己搬运
dodois

dodois commented on Oct 31, 2020

@dodois

开源免费的梯子 https://github.com/dodois/dosvpn

ovenx

ovenx commented on Dec 27, 2020

@ovenx

https://github.com/ovenx/github-hosts 自动从 ipaddress.com 获取 github ip 地址

SunXinFei

SunXinFei commented on Jan 15, 2021

@SunXinFei

这个根本没啥用,搭个梯子,配置一下域名代理,基本就 OK 了。

image

.github.com
||github.com
github.global.ssl.fastly.net
.githubassets.com
||githubassets.com
.githubusercontent.com
||githubusercontent.com

打开速度飞快

image

没用代理之前,慢到令人发指:

image

git clone 的时候也要配置一下 socket5 代理,速度也是提升很多。

git clone 代理设置

首先确保梯子可正常使用,软件建议使用 v2ray。

https访问
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

其中1080是 socks5 的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1080.

设置完成后, ~/.gitconfig 文件中会增加以下条目:

[http "https://github.com"]  proxy = socks5://127.0.0.1:1080

如果不想用梯子正常访问,可以考虑取消代理设置

git config --global --unset http.https://github.com.proxy
ssh访问

需要修改 ~/.ssh/config 文件, 没有的话新建一个. 同样仅为github.com设置代理:

Host github.com  User git  ProxyCommand nc -v -x 127.0.0.1:1080 %h %p

配置代理前后速度对比图

image

同理 homebrew 这种代理方式也适用,用 brew 下载速度飞起。

设置了socket 很快

hexiaowu

hexiaowu commented on Jan 17, 2021

@hexiaowu

这个根本没啥用,搭个梯子,配置一下域名代理,基本就 OK 了。

image

.github.com
||github.com
github.global.ssl.fastly.net
.githubassets.com
||githubassets.com
.githubusercontent.com
||githubusercontent.com

打开速度飞快

image

没用代理之前,慢到令人发指:

image

git clone 的时候也要配置一下 socket5 代理,速度也是提升很多。

git clone 代理设置

首先确保梯子可正常使用,软件建议使用 v2ray。

https访问
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

其中1080是 socks5 的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1080.

设置完成后, ~/.gitconfig 文件中会增加以下条目:

[http "https://github.com"]  proxy = socks5://127.0.0.1:1080

如果不想用梯子正常访问,可以考虑取消代理设置

git config --global --unset http.https://github.com.proxy
ssh访问

需要修改 ~/.ssh/config 文件, 没有的话新建一个. 同样仅为github.com设置代理:

Host github.com  User git  ProxyCommand nc -v -x 127.0.0.1:1080 %h %p

配置代理前后速度对比图

image

同理 homebrew 这种代理方式也适用,用 brew 下载速度飞起。

老哥,Host github.com User git ProxyCommand nc -v -x 127.0.0.1:1080 %h %p 这个配置了,SSH clone 项目速度还是慢的跟乌龟一样啊,配置好后是需要做什么吗?

配置了 git config --global http.https://github.com.proxy socks5://127.0.0.1:1080 ,http clone的速度倒是提升了很多。

wu-yue-yu

wu-yue-yu commented on Jan 21, 2021

@wu-yue-yu

开源免费的梯子 https://github.com/dodois/dosvpn

谢谢老哥了,这个访问github是真的快

pigpigchacha

pigpigchacha commented on Feb 22, 2021

@pigpigchacha

能加速github和git clone的梯子,完美解决方案:https://github.com/pigpigchacha/GitProxy

gauseen

gauseen commented on May 19, 2021

@gauseen

安装 Chrome 插件就可以 FasterHosts

  1. 下载 FasterHosts 然后解压,找到 extension 子目录
  2. 打开 Chrome,输入: chrome://extensions/
  3. 打开「开发这模式」
  4. 选择「加载已解压的扩展程序」,然后定位到刚才解压的文件夹里面的 extension 目录,确定
  5. 这就安装好了,关闭「开发这模式」
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chilly@archonwang@ximply@dbarobin@ptsa

        Issue actions

          GitHub中国加速访问 · Issue #3 · chenxuhua/issues-blog