cURL / Mailing Lists / curl-library / Single Mail


libcurl custom dns not failing (when bad dns ip configured with CURLOPT_DNS_SERVERS )

From: Stefan Rogin <>
Date: Mon, 25 Nov 2013 15:04:33 +0200


I've made a multithreaded (pthread) c++ program that is configured to use
a list of custom dns.
In my tests I've used google's for good ex, and some random ip like, to test fail. But all goes the same in both
cases, successfully.

Curl was built with C-ares support, and I've tested just to be sure:
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
 cout<<endl<<"Curl version: "<< data->version <<endl
<<"AsyncDNS: "<<( data->features | CURL_VERSION_ASYNCHDNS ? "YES" : "NO" )
 //output: Curl version: 7.30.0 \n AsyncDNS: YES
The rest of the code:
 curl_easy_setopt(curl, CURLOPT_DNS_SERVERS,
 curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE,false); //thread safety
 curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
 curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 5);
 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_to_string);
 curl_easy_setopt(curl, CURLOPT_WRITEHEADER, &getUrlOutput->header);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &getUrlOutput->html);
 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
 curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip,deflate");

I've tested the random IPs (just in case I've stumbled on some valid DNS) :
$ host
;; connection timed out; no servers could be reached
$ host
;; connection timed out; no servers could be reached

What am I missing ?

Thank you

*Stefan Rogin*
Web designer & developer, Software Developer, Data Analyst

List admin:
Received on 2013-11-25