当我尝试使用 curl 调用 query.yahooapis.com 时,它会尝试使用 ipv6 地址,但我的电脑上已禁用 IPV6
$ curl -v 'http://query.yahooapis.com/'
* Hostname was NOT found in DNS cache
* Trying 98.137.200.255...
* Trying 2001:4998:58:2201::1010...
* Immediate connect fail for 2001:4998:58:2201::1010: No route to host
* Trying 2001:4998:58:2201::1010...
* Immediate connect fail for 2001:4998:58:2201::1010: No route to host
* Trying 2001:4998:58:2201::1010...
* Immediate connect fail for 2001:4998:58:2201::1010: No route to host
* Trying 2001:4998:58:2201::1010...
* Immediate connect fail for 2001:4998:58:2201::1010: No route to host
我的ifconfig:
$ ifconfig en1
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether b0:34:95:f0:2c:46
inet 192.168.0.13 netmask 0xffffff00 broadcast 192.168.0.255
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
我正在使用 Yosemite 10.10.2
有什么想法可以解决这个问题吗?
答案1
在您的示例中,curl 首先尝试通过 IPv4 进行连接,只有在失败时才开始尝试 IPv6。我同意,对于您来说,这没什么用(您确实应该找到提供 IPv6 的 ISP),但我也不认为这是一个问题,因为它已经尝试过 IPv4。
答案2
您可以要求 curl 明确使用 IPv4:
卷曲-4 -v'http://query.yahooapis.com/‘