当我进行 curl 时,它说无法解析主机,我该怎么办?
curl http://npmjs.org/install.sh | sudo sh
curl: (6) Couldn't resolve host 'npmjs.org'
/etc/resolv.conf
search x1
nameserver x2
nameserver 8.8.8.8
nameserver 8.8.4.4
nslookup 结果
nslookup google.com
Server: x1
Address: x1#53
Non-authoritative answer:
*** Can't find google.com: No answer
非权威答案:*** 找不到 google.com:无答案
答案1
确保您的 DNS 工作正常:
$ nslookup google.com
如果没有,请更改为Google的DNS并重试:
# echo "nameserver 8.8.8.8" > /etc/resolv.conf
# echo "nameserver 8.8.4.4" >> /etc/resolv.conf
我可以通过代理访问互联网
您可以curl
使用以下 HTTP 代理:
$ curl -x proxyhost:port http://npmjs.org/install.sh | sudo sh