1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_DNS_SHUFFLE_ADDRESSES
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_DNS_CACHE_TIMEOUT (3)
9  - CURLOPT_IPRESOLVE (3)
10Protocol:
11  - All
12---
13
14# NAME
15
16CURLOPT_DNS_SHUFFLE_ADDRESSES - shuffle IP addresses for hostname
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SHUFFLE_ADDRESSES, long onoff);
24~~~
25
26# DESCRIPTION
27
28Pass a long set to 1 to enable this option.
29
30When a name is resolved and more than one IP address is returned, this
31function shuffles the order of all returned addresses so that they are used in
32a random order. This is similar to the ordering behavior of the legacy
33gethostbyname function which is no longer used on most platforms.
34
35Addresses are not reshuffled if name resolution is completed using the DNS
36cache. CURLOPT_DNS_CACHE_TIMEOUT(3) can be used together with this
37option to reduce DNS cache timeout or disable caching entirely if frequent
38reshuffling is needed.
39
40Since the addresses returned are randomly reordered, the order is not in
41accordance with RFC 3484 or any other deterministic order that may be
42generated by the system's name resolution implementation. This may have
43performance impacts and may cause IPv4 to be used before IPv6 or vice versa.
44
45# DEFAULT
46
470 (disabled)
48
49# EXAMPLE
50
51~~~c
52int main(void)
53{
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
57    curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
58
59    curl_easy_perform(curl);
60
61    /* always cleanup */
62    curl_easy_cleanup(curl);
63  }
64}
65~~~
66
67# AVAILABILITY
68
69Added in 7.60.0
70
71# RETURN VALUE
72
73CURLE_OK or an error such as CURLE_UNKNOWN_OPTION.
74