GNURLOPT_DNS_INTERFACE(3)
π NAME π
Okay bestie, welcome to GNURLOPT_DNS_INTERFACE(3) from the curl_easy_setopt options manual β this is the page about setting the interface your DNS resolver should speak over. The actual option name is CURLOPT_DNS_INTERFACE, and it's giving βtell DNS to bind to this network interfaceβ energy. β¨
π SYNOPSIS π
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_INTERFACE, char *ifname);
πΈ DESCRIPTION πΈ
You pass a char * as the parameter, bestie β literally that's the move. Set it to the name of the network interface that the DNS resolver should bind to.
Important vibe check: this must be an interface name (not an address). So like, the name, not the IP. No cap. π
Set this option to NULL to use the default setting (don't bind to a specific interface). Easy.
And good news for your app: the application does not have to keep the string around after setting this option. Set it and move on. π«Ά
β DEFAULT β
NULL
π¦ PROTOCOLS π¦
There's literally nothing listed in this section on the original page, so no protocol list to show you here, bestie. That's the whole section. π
π₯ EXAMPLE π₯
Here's the example, exactly as the page gives it:
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
curl_easy_setopt(curl, CURLOPT_DNS_INTERFACE, "eth0");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
π AVAILABILITY π
Added in 7.33.0. This option also requires that libcurl was built with a resolver backend that supports this operation. The c-ares backend is the only such one. So yeah β backend check first, bestie. β¨
π RETURN VALUE π
Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or CURLE_NOT_BUILT_IN if support was disabled at compile-time. That's the whole return-value menu. π
π SEE ALSO π
Later, bestie! This page is from libcurl 7.37.0, dated 19 Jun 2014, and it's the GNURLOPT_DNS_INTERFACE(3) page. Mwah! π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms