cURL / Mailing Lists / curl-library / Single Mail


Prepopulate DNS cache with IPv6 and IPv4 address

From: Thomas Glanzmann <>
Date: Wed, 13 Jan 2016 09:05:02 +0100

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

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <fcntl.h>

static CURLcode
prepoulate_dns_cache(CURL *curl)
        struct curl_slist *host = NULL;
        host = curl_slist_append(host, "");
        host = curl_slist_append(host, "");
        return curl_easy_setopt(curl, CURLOPT_RESOLVE, host);

main(int argc, char **argv)
        CURL *curl = NULL;
        char *errbuf;

        errbuf = malloc(CURL_ERROR_SIZE);
        if (errbuf == NULL)

        curl = curl_easy_init();
        if (! curl) {

        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
        curl_easy_setopt(curl, CURLOPT_URL, "");

        return 0;

* Added to DNS cache
* Added to DNS cache
* timeout on name lookup is not supported
* Hostname was found in DNS cache
* Trying 2a01:4f8:b0:2fff::2...
* connect to 2a01:4f8:b0:2fff::2 port 443 failed: Network unreachable
* Failed to connect to port 443: Network unreachable
* Closing connection 0

List admin:
Received on 2016-01-13