GitHub 訪問不了?用這個方法輕松解決
Github是全球最大的代碼開源平臺,許多程序員都會通過它尋找一些優(yōu)質的開源項目,或者在上面托管自己創(chuàng)建的開源項目,從而提升自己。
不知道大家最近有沒有出現(xiàn)這種情況,Github總是突然無法訪問,解析出來的幾個IP都是不定時出現(xiàn)tcp connect time out,而且就算連接成功了,下次在連接,相同的IP也很容易連接失敗,據(jù)某位知乎大佬給出的猜測是旁路識別出SSL證書后,開始阻止新的鏈接,若干秒后才會解除。
還好,猿妹在Github上找到一個開源項目,就是幫助大家解決這個問題的,使用方法十分簡單,小白也能操作。
這個項目無需安裝任何程序,通過修改本地 hosts 文件,試圖解決:
- GitHub 訪問速度慢的問題
- GitHub 項目中的圖片顯示不出的問題
使用方法
首先,你需要復制以下內容:
- # GitHub520 Host Start
- 185.199.108.154 github.githubassets.com
- 140.82.114.21 central.github.com
- 185.199.108.133 desktop.githubusercontent.com
- 185.199.108.153 assets-cdn.github.com
- 185.199.108.133 camo.githubusercontent.com
- 185.199.108.133 github.map.fastly.net
- 199.232.69.194 github.global.ssl.fastly.net
- 140.82.113.4 gist.github.com
- 185.199.108.153 github.io
- 140.82.114.3 github.com
- 140.82.113.5 api.github.com
- 185.199.108.133 raw.githubusercontent.com
- 185.199.108.133 user-images.githubusercontent.com
- 185.199.108.133 favicons.githubusercontent.com
- 185.199.108.133 avatars5.githubusercontent.com
- 185.199.108.133 avatars4.githubusercontent.com
- 185.199.108.133 avatars3.githubusercontent.com
- 185.199.108.133 avatars2.githubusercontent.com
- 185.199.108.133 avatars1.githubusercontent.com
- 185.199.108.133 avatars0.githubusercontent.com
- 185.199.108.133 avatars.githubusercontent.com
- 140.82.113.10 codeload.github.com
- 52.216.226.40 github-cloud.s3.amazonaws.com
- 52.216.162.99 github-com.s3.amazonaws.com
- 52.216.142.196 github-production-release-asset-2e65be.s3.amazonaws.com
- 52.217.97.236 github-production-user-asset-6210df.s3.amazonaws.com
- 52.217.194.41 github-production-repository-file-5c1aeb.s3.amazonaws.com
- 185.199.108.153 githubstatus.com
- 64.71.168.201 github.community
- 185.199.108.133 media.githubusercontent.com
- # Update time: 2021-03-24T16:06:33+08:00
- # Star me GitHub url: https://github.com/521xueweihan/GitHub520
- # GitHub520 Host End
接著,你需要去修改 hosts 文件,hosts 文件在每個系統(tǒng)的位置不一,詳情如下:
- Windows 系統(tǒng):C:\Windows\System32\drivers\etc\hosts
- Linux 系統(tǒng):/etc/hosts
- Mac(蘋果電腦)系統(tǒng):/etc/hosts
- Android(安卓)系統(tǒng):/system/etc/hosts
- iPhone(iOS)系統(tǒng):/etc/hosts
修改方法,把第一步的內容復制到文本末尾:
- Windows 使用記事本。
- Linux、Mac 使用 Root 權限:sudo vi /etc/hosts。
- iPhone、iPad 須越獄、Android 必須要 root。
大部分情況下是直接生效,如未生效可嘗試下面的辦法,刷新 DNS:
- Windows:在 CMD 窗口輸入:ipconfig /flushdns
- Linux 命令:sudo rcnscd restart
- Mac 命令:sudo killall -HUP mDNSResponder
是不是覺得超級簡單?目前,GitHub520已經在Github上標星 4.1K,累計分支 348 個(Github地址:https://github.com/521xueweihan/GitHub520)
如果你的Github在訪問時也出現(xiàn)圖裂、或者加載緩慢等問題,不妨試試。Github520,讓你重新愛上Github。