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