使用 dns 选项运行 CURL 时出现问题

使用 dns 选项运行 CURL 时出现问题

我现在正在使用 curl 来调试我的非生产 Web 服务。

当我使用该--dns-servers选项时,我总是收到未找到此功能的错误:

curl --dns-servers _MY_DNS_SERVER_IP_ https://_MY_DOMAINS_
curl: (4) A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.

我的curl版本是7.47.0,运行在Ubuntu 16.04桌面上。

来自 curl 手册页:

This option requires that libcurl was built with a resolver backend that supports this operation.
The c-ares backend is the only such one.  (Added in 7.33.0)

有什么提示可以说明是什么问题吗?

是否需要安装其他 curl 包,或者我遗漏了一些可选依赖项?

答案1

好的,经过大量时间尝试解决这个问题之后,我想为未来遇到此问题的用户回答这个问题。

根据 StackExchange 用户bk2204我的问题:

为 Debian 和 Ubuntu 构建的二进制文件curl不包含对 libc-ares 的支持。这是因为该库无法返回单个响应中同时包含 A (IPv4) 和 AAAA (IPv6) 查询,因此如果您连接的主机使用 IPv6 但您不支持 IPv6,则连接会失败。由于这是一个相当大的缺陷(因为许多开放式 Wi-Fi 接入点没有 IPv6),Debian 和 Ubuntu 已将其编译出来。

您可能能够使用--resolve手动指定要使用的 IP 地址。否则,如果您需要使用此功能,则必须编译自己的 curl。

链接到问题以获取未来的更新(如果有):使用 dns 选项运行 CURL 时出现问题(Unix 和 Linux 社区)

相关内容