CURLOPT_DNS_SERVERS.3 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .\" generated by cd2nroff 0.1 from CURLOPT_DNS_SERVERS.md
  2. .TH CURLOPT_DNS_SERVERS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_DNS_SERVERS \- DNS servers to use
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char *servers);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a char pointer that is the list of DNS servers to be used instead of the
  12. system default. The format of the dns servers option is:
  13. host[:port][,host[:port]]...
  14. For example:
  15. 192.168.1.100,192.168.1.101,3.4.5.6
  16. The application does not have to keep the string around after setting this
  17. option.
  18. .SH DEFAULT
  19. NULL
  20. .SH PROTOCOLS
  21. This functionality affects all supported protocols
  22. .SH EXAMPLE
  23. .nf
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. if(curl) {
  28. CURLcode res;
  29. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  30. curl_easy_setopt(curl, CURLOPT_DNS_SERVERS,
  31. "192.168.1.100:53,192.168.1.101");
  32. res = curl_easy_perform(curl);
  33. curl_easy_cleanup(curl);
  34. }
  35. }
  36. .fi
  37. .SH NOTES
  38. This option requires that libcurl was built with a resolver backend that
  39. supports this operation. The c\-ares backend is the only such one.
  40. .SH AVAILABILITY
  41. Added in curl 7.24.0
  42. .SH RETURN VALUE
  43. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not,
  44. CURLE_NOT_BUILT_IN if support was disabled at compile\-time,
  45. CURLE_BAD_FUNCTION_ARGUMENT when given an invalid server list, or
  46. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  47. .SH SEE ALSO
  48. .BR CURLOPT_DNS_CACHE_TIMEOUT (3),
  49. .BR CURLOPT_DNS_LOCAL_IP4 (3),
  50. .BR CURLOPT_DNS_LOCAL_IP6 (3)