更新于: 2021
原因:DNS污染或其他原因導致域名不能解析到ip
解決方案:直接添加域名映射ip即可
一.Mac 環境下:
第1步:終端輸入 sudo vi /etc/hosts 后 輸入密碼
第2步:按i
進入INSERT模式,拷貝下方內容放到最下面一個~
處
# GitHub Start
140.82.114.4 github.com
140.82.114.4 gist.github.com
185.199.108.153 assets-cdn.github.com
151.101.64.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
# GitHub End
按下i后把光標移動到最后再按下回車即可另起一行,command + v粘貼上面的內容即可,截圖只是示意,這個解析的ip有時候會改變,雖然也能ping通,但是不能加載出圖片
輸入內容
第3步:點擊esc
鍵,再輸入:wq
保存退出,刷新頁面即可看到效果。
也可以將此文件拷貝桌面后修改,改完后覆蓋放回。
二.Windows 環境下:
第1步:找到C:\Windows\System32\drivers\etc\hosts打開
第2步:加入上述內容在末尾,保存刷新網頁即可
三.終極解決方案
如果以上操作還是不行,說明域名解析的ip仍是不對,那就需要我們自己去找了,以Chrome為例,按F12打開控制臺,點開元素審查,選擇圖片,會看到圖片的url,拿到域名后在域名解析網站上進行解析,就能獲取到真正的ip地址,此時,將其按照上述方式加到host文件中即可。