打開Nuget,發現又出問題了:未能解析此遠程名稱:’nuget.org’。
在瀏覽器中輸入 http://nuget.org 會發現是無法打開的。
在cmd命令行里輸入: nslookup nuget.org 一般也是無法解析到這個域名的ip地址。
不過在cmd命令行里輸入: nslookup nuget.org 8.8.8.8 向谷歌的dns查詢這個域名,便能正確返回域名對應ip地址。
為什么使用dhcp自動獲取的dns服務器就無法解析nuget.org 這個域名呢?
輸入如下命令: nslookup –type=ns nuget.org 8.8.8.8 查詢該域名的NameServer 服務器,會發現nuget.org使用的godaddy的域名服務器,而godaddy的域名服務器在國內被大規模屏蔽,所以在國內的dns服務器自然查詢不到該域名,也自然出現了未能解析此遠程名稱咯!
解決方法有二:
1.修改hosts文件。通過上面第二條命令獲取了nuget.org的真實地址后,直接添加到hosts文件中。如:157.56.8.150 nuget.org
2.修改電腦的dns服務器,不要用自動獲取的dns,而是直接修改為opendns或是谷歌的dns。如8.8.8.8