解決國內訪問github速度慢的問題


從簡書中轉載:

https://www.jianshu.com/p/66facbd8926a

 

由於某些原因,國內訪問github會異常緩慢,在clone倉庫時甚至只有10k一下的速度,下載半天也下不完。

 

本文介紹通過修改系統hosts文件的棒啊,繞過國內dns解析,直接訪問github的cdn節點,從而達到加速的目的。

 

1.進入github官方cdn地址

https://www.ipaddress.com/

 

2.查詢下面兩個連接的dns解析地址

github.com

github.global.ssl.fastly.net

 

3.修改系統hosts文件

打開系統hosts文件(管理員權限)

windows路徑:C:\Windows\System32\drivers\etc

mac打開方式 sudo vim /etc/hosts

 

 

在末尾添加三行記錄並保存。注意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

199.232.69.194 github.global.ssl.fastly.net

 

4.刷新系統dns緩存

windows:

Windows + X 打開系統命令行(管理員身份)或者 powershell

運行 ipconfig /flushdns 手動刷新系統dns緩存

mac:

sudo killall -HUP mDNSResponder

 

 

5.大功告成

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM