CURLOPT_DNS_SHUFFLE_ADDRESSES(3)
π CURLOPT_DNS_SHUFFLE_ADDRESSES(3) β¨
okay so bestie, this one lives in the libcurl Library Functions Manual, and it's literally the "make my IP addresses come out in a random order" option π
πΈ NAME πΈ
CURLOPT_DNS_SHUFFLE_ADDRESSES β shuffle IP addresses for hostname π¦
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SHUFFLE_ADDRESSES, long onoff);
π DESCRIPTION π
okay so you pass a long set to 1 to enable this option. that's it. that's the vibe π
When a name is resolved and more than one IP address is returned, this function shuffles the order of all returned addresses so that they are used in a random order π. It's similar to the ordering behavior of the legacy gethostbyname function β yk, the one that is no longer used on most platforms π.
ngl, addresses are not reshuffled if name resolution is completed using the DNS cache. so if you need frequent reshuffling, CURLOPT_DNS_CACHE_TIMEOUT(3) can be used together with this option to reduce the DNS cache timeout, or to disable caching entirely π
and here's the caveat, bestie, listen up π’ β since the addresses returned are randomly reordered, the order is not in accordance with RFC 3484 or any other deterministic order that may be generated by the system's name resolution implementation. This may have performance impacts π and may cause IPv4 to be used before IPv6 or vice versa. it's giving chaos, but like, intentional chaos π
π DEFAULT π
0 (disabled) β she's off unless you say otherwise π«Ά
π PROTOCOLS π
This functionality affects all supported protocols. all of them. every single one πβ¨
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
}
the /* always cleanup */ comment is doing main character energy ngl π§
β AVAILABILITY β
Added in curl 7.60.0 β so she's been iconic for a minute π
π₯ RETURN VALUE π₯
CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. that's the whole list, no cap π
π¦ SEE ALSO π¦
and that's the page, bestie!! π«Ά this one came from libcurl, dated 2026-10-12, and the header up top was CURLOPT_DN...E_ADDRESSES(3) (yes the title really is truncated like that in the manual, iykyk ππ). mwah, go shuffle some addresses responsibly β¨π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms