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

Piz*_*zza 2 networking ubuntu dns webserver curl

我现在使用 curl 一段时间来调试我的非生产网络服务。

当我使用该--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.
Run Code Online (Sandbox Code Playgroud)

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

从 curl 手册页(关于--dns-servers选项):

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)
Run Code Online (Sandbox Code Playgroud)

是否需要安装另一个 curl 包,或者我错过了一些可选的依赖项?

任何提示似乎是什么问题?

bk2*_*204 5

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

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