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