登录
原创

如何加速国内Github访问

发布于 2021-03-13 阅读 1224
  • GitHub
原创

由于某些原因,国内访问Github会异常缓慢,在clone仓库时甚至只有10k以下的速度,下载半天有时还会失败需要从头再来,甚是让人恼火。
本文介绍通过修改系统hosts文件的办法,绕过国内dns解析,直接访问GitHub的CDN节点,从而达到加速的目的。不需要科学上网,也不需要海外的服务器辅助。

1 获取GitHub官方CDN地址
打开https://www.ipaddress.com/

查询以下三个链接的DNS解析地址

  1. github.com
  2. assets-cdn.github.com
  3. github.global.ssl.fastly.net
image

记录下查询到的IP地址。

2 修改系统Hosts文件
打开系统hosts文件(需管理员权限)。
路径:C:\Windows\System32\drivers\etc

在末尾添加三行记录并保存。(需管理员权限,注意IP地址与域名间需留有空格)

<button class="VJbwyy" type="button" aria-label="复制代码"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="copy" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"></path></svg></button>
# Copyright (c) 1993-2009 Microsoft Corp.
#
# 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
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

192.30.253.112 github.com

151.101.72.133 assets-cdn.github.com

151.101.193.194 github.global.ssl.fastly.net

3 刷新系统DNS缓存
Windows+X 打开系统命令行(管理员身份)或powershell

运行 ipconfig /flushdns 手动刷新系统DNS缓存。

image

现在打开Github,clone一个项目到本地试试吧,作者这电信的宽带会轻松达到10M/s的速度。

评论区

励志做一条安静的咸鱼,从此走上人生巅峰。

0

0

0

举报