【问题标题】:What is different between CURLOPT_DNS_SERVERS and CURLOPT_DNS_LOCAL_IP4 in curl optioncurl选项中的CURLOPT_DNS_SERVERS和CURLOPT_DNS_LOCAL_IP4有什么不同
【发布时间】:2022-01-05 04:45:51
【问题描述】:

下面两个代码的具体区别是什么?

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, "192.168.0.100");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}
CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.100");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

主要是与CURLOPT_DNS_SERVERSCURLOPT_DNS_LOCAL_IP4相关的问题。

【问题讨论】:

    标签: curl dns


    【解决方案1】:

    比较https://curl.se/libcurl/c/CURLOPT_DNS_SERVERS.htmlhttps://curl.se/libcurl/c/CURLOPT_DNS_LOCAL_IP4.html看看区别,主要是:

    • “为CURLOPT_DNS_SERVERS 传递一个字符*,它是要使用的DNS 服务器列表,而不是系统默认值”
    • “设置解析器应该绑定的本地 IPv4 地址。”对于CURLOPT_DNS_LOCAL_IP4

    第二种情况应该很少需要,它强制一个特定的本地 IPv4 地址(如果该框有多个)用于任何传出的 DNS 查询。

    第一个选项设置要联系的服务器。

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 1970-01-01
      • 2019-07-07
      • 2012-08-30
      • 1970-01-01
      • 2015-02-05
      • 2017-01-29
      • 2011-06-17
      • 2014-08-15
      相关资源
      最近更新 更多