CURLOPT_DNS_INTERFACE(3)
π CURLOPT_DNS_INTERFACE(3) β the curl library functions manual, bestie edition π
okay so real talk, this page lives in the libcurl corner of the manual (the Library Functions Manual one), and it's about CURLOPT_DNS_INTERFACE(3). yes that's the whole title. slay. let's get into it β¨
π¦ NAME
CURLOPT_DNS_INTERFACE β the interface to speak DNS over, periodt
πΈ SYNOPSIS
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_INTERFACE, char *ifname);
that's it. that's the whole vibe check. handle is your curl handle, ifname is the interface name, and it comes back at you as a CURLcode. π«Ά
π DESCRIPTION
so you pass a char pointer as the parameter, and what it does is set the name of the network interface that the DNS resolver should bind to. key detail, bestie: it has to be an interface name, not an address. like "eth0" energy, not "192.168.1.5" energy. do not mix those up, i'm literally begging π
and if you set this option to NULL, it just goes back to the default setting, which is not binding to a specific interface at all. freedom. no cap.
also, good news: the application does not have to keep the string around after setting this option. you can let it go, she's fine, she's got her own copy π
setting this option multiple times? the last string you set overrides all the previous ones. last one wins, main character energy only π. and setting it to NULL disables its use again.
π DEFAULT
NULL
(no interface bound, just vibes π)
π₯ PROTOCOLS
this functionality affects all supported protocols. all of them. every single one. iconic β
β¨ EXAMPLE
here's the whole thing, copy it exactly, don't @ 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_INTERFACE, "eth0");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
look at her go, binding DNS to eth0 and fetching https://example.com/foo.bin. we love a functional snippet π§
π NOTES
β οΈ okay this is the important caveat so listen up: 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 not on c-ares, this option is giving nothing. literally nothing. check your build first bestie π
π AVAILABILITY
Added in curl 7.33.0. vintage. a classic π
π RETURN VALUE
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK. non-zero means an error occurred β go check libcurl-errors(3) for the tea π΅.
π¦ SEE ALSO
okay that's the whole page, you're officially educated π this was libcurl, dated 2026-10-12, and the page was CURLOPT_DNS_INTERFACE(3) β go bind an interface, stay hydrated, and remember: interface name, not address. mwah π«Άβ¨
π¦ 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