CURLOPT_DNS_LOCAL_IP6(3)
π CURLOPT_DNS_LOCAL_IP6(3) β the libcurl one, from the Library Functions Manual
okay bestie, sit down, we're talking about CURLOPT_DNS_LOCAL_IP6 today and honestly it's a whole vibe. tiny little option, does exactly one thing, and does it slay.
β¨ NAME β¨
CURLOPT_DNS_LOCAL_IP6 β the IPv6 address your DNS resolves get bound to π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP6, char *address);
π¦ DESCRIPTION π¦
so here's the tea: you're setting the local IPv6 address that the resolver should bind to. that's it, that's the function.
the argument is supposed to be a char * and it should hold a single IPv6 address as a string. one. just the one. don't get cute.
set this option to NULL and you get the default setting back β meaning do not bind to a specific IP address. release the address, live your life. π
and the best part? the application does not have to keep the string around after setting this option. libcurl takes its own copy, so you can free your string the second the call returns. no strings attached, literally. π«Ά
calling this option multiple times? totally fine β the last set string overrides the previous ones. last one in wins, periodt. and if you want to disable it entirely again, just set it to NULL. iconic behavior honestly.
π DEFAULT π
NULL
(no binding, no drama β¨)
π PROTOCOLS π
this functionality affects all supported protocols. all of them. every single one. no cap. π
π EXAMPLE π
here's what it looks like in the wild, copy it exactly, don't come for me:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP6, "fe80::a9ff:fe46:b619");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
that fe80::a9ff:fe46:b619 is giving link-local main character energy and we love her. π§
β NOTES β
β οΈ important warning time, bestie, do not skip this: this option requires that libcurl was built with a resolver backend that supports this operation. and the c-ares backend is the only such one. so if you're on some other backend, this option is not gonna do the thing. check your build, iykyk. π
π AVAILABILITY π
added in curl 7.33.0 β she's been around a minute, she's a classic. π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode, which is either success or an error, no in-between.
CURLE_OK(0) β everything was OK, we ate, no crumbs. β- non-zero β an error occurred, something went wrong, see
libcurl-errors(3)for the whole lore. π
π₯ SEE ALSO π₯
go read the rest of the DNS family, they're all serving. π¦
and that's the page sksksk β brought to you by libcurl, dated 2026-10-12, filed under CURLOPT_DNS_LOCAL_IP6(3) in the Library Functions Manual. mwah, stay bound to the right address bestie ππ
π¦ 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