GNURLOPT_DNS_SERVERS(3)

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

hey bestie πŸ’– welcome to GNURLOPT_DNS_SERVERS(3), one of the curl_easy_setopt options pages β€” and it's here to spill the tea on setting preferred DNS servers. no cap, it's a whole vibe. ✨

πŸŽ€ NAME πŸŽ€

CURLOPT_DNS_SERVERS β€” set preferred DNS servers. that's the assignment, and it ate. πŸ’…

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char
*servers);

πŸ’… DESCRIPTION πŸ’…

okay so you pass a char * that is the list of DNS servers to be used instead of the system default. lowkey powerful. 🫢

the format of the dns servers option is:

host[:port][,host[:port]]...

for example:

192.168.1.100,192.168.1.101,3.4.5.6

and the best part? the application does not have to keep the string around after setting this option. once it's set, you can let that string go. periodt. πŸ’–

πŸ¦‹ DEFAULT πŸ¦‹

NULL - use system default. that's the default, bestie. no extra DNS drama. 🌸

🌈 PROTOCOLS 🌈

All β€” every protocol, no cap. 🌟

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
  curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, "192.168.1.100:53,192.168.1.101");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

πŸ’œ AVAILABILITY πŸ’œ

this option requires that libcurl was built with a resolver backend that supports this operation. the c-ares backend is the only such one. so yeah, check your build before you get too excited 😭

Added in 7.24.0. πŸŽ€

πŸ”₯ RETURN VALUE πŸ”₯

  • CURLE_OK β€” if the option is supported.
  • CURLE_UNKNOWN_OPTION β€” if not.
  • CURLE_NOT_BUILT_IN β€” if support was disabled at compile-time.
  • CURLE_BAD_FUNCTION_ARGUMENT β€” when given an invalid server list.
  • CURLE_OUT_OF_MEMORY β€” if there was insufficient heap space.

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’– that's the whole page, bestie! brought to you by libcurl 7.37.0, dated 19 Jun 2014, and filed under GNURLOPT_DNS_SERVERS(3). mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from