cURL / Mailing Lists / curl-library / Single Mail


Re: Prepopulate DNS cache with IPv6 and IPv4 address

From: Daniel Stenberg <>
Date: Wed, 13 Jan 2016 10:18:34 +0100 (CET)

On Wed, 13 Jan 2016, Thomas Glanzmann wrote:

> I would like to prepopulate the DNS cache with a IPv6 (preferred) and a IPv4
> address. When I try to do the same it works perfectly if the host is dual
> stack, but not if it is IPv4 only. How was the usage for such a scenario
> intended? I assumed that it would even try IPv4 if no IPv6 is available.

I can see that it isn't sufficiently documented, and quite frankly I think we
didn't really implement it for that kind of (still sensible) use case. The
(my) thinking was more to make a better version of using the IP in the URL and
providing your own Host: header.

The CURLOPT_RESOLVE feature is actually simpler than so. It stores a *single*
address for a given host+port combo, and it will not overwrite an existing
entry. So in your case:

     host = curl_slist_append(host, "");
     host = curl_slist_append(host, "");

libcurl will only store the first address and not the second one, which then
will have it attempt to use the IPv6 address when is used.

There have been work in the past to make it support multiple addresses per
host+port pair, and I think it would be a great addition.

Separately from that, I don't think we deal with the situation where you
populate the cache with an IPv6 adress for a library that otherwise can't use
IPv6 as it cannot otherwise put such an address in there. This is another
issue we should address somehow, at the very least by documenting it.

List admin:
Received on 2016-01-13