![我正在尝试打开 query.yahooapis.com,但 curl 尝试使用 IPV6,即使我只启用了 IPV4](https://linux22.com/image/1468658/%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%9D%E8%AF%95%E6%89%93%E5%BC%80%20query.yahooapis.com%EF%BC%8C%E4%BD%86%20curl%20%E5%B0%9D%E8%AF%95%E4%BD%BF%E7%94%A8%20IPV6%EF%BC%8C%E5%8D%B3%E4%BD%BF%E6%88%91%E5%8F%AA%E5%90%AF%E7%94%A8%E4%BA%86%20IPV4.png)
当我尝试使用 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/‘