最近打算維護一個自己的東西,突然發現上傳的圖片時不時的打不開,很是無語,看到一老哥的博文,嘗試一波:
問題原因截圖如下:
解決方案如下:
Step 1:在加載失敗的圖片選擇檢查,找到 GitHub 二級域名
這裏拿到 GitHub 二級域名如下:
- raw.githubusercontent.com
Step 2:在 IP 網站查詢此 IP 段
如下所示,GitHub 在 2020 年 1 月 4 日調整了 IP 段:
Step 3:修改本地 hosts 文件
在 iTerm 2,鍵入如下命令:
- sudo vi /etc/hosts
隨後,點擊 i 進入 Insert 模式,將如下內容複製即可:
# GitHub Start
192.30.253.112 github.com
192.30.253.119 gist.github.com
199.232.28.133 assets-cdn.github.com
199.232.28.133 raw.githubusercontent.com
199.232.28.133 gist.githubusercontent.com
199.232.28.133 cloud.githubusercontent.com
199.232.28.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
# GitHub End
隨後,點擊 esc 鍵,輸入 wq 保存退出即可。
Step 4:覈驗結果
搞定~