加速國內(nèi)的Github的訪問

由于某些原因,國內(nèi)訪問Github會異常緩慢,在clone倉庫時甚至只有10k以下的速度,下載半天有時還會失敗需要從頭再來,甚是讓人惱火。
本文介紹通過修改系統(tǒng)hosts文件的辦法,繞過國內(nèi)dns解析,直接訪問GitHub的CDN節(jié)點,從而達到加速的目的。不需要科學上網(wǎng),也不需要海外的服務(wù)器輔助。

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 修改系統(tǒng)Hosts文件
打開系統(tǒng)hosts文件(需管理員權(quán)限)。
路徑:C:\Windows\System32\drivers\etc

在末尾添加三行記錄并保存。(需管理員權(quán)限,注意IP地址與域名間需留有空格)

# 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 刷新系統(tǒng)DNS緩存
Windows+X 打開系統(tǒng)命令行(管理員身份)或powershell

運行 ipconfig /flushdns 手動刷新系統(tǒng)DNS緩存。

image

現(xiàn)在打開Github,clone一個項目到本地試試吧。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容