GNURLOPT_DNS_INTERFACE(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’– 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