GNURLOPT_DNS_SERVERS(3)
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
- 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