CURLOPT_DNS_SERVERS.md (1644B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_DNS_SERVERS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_DNS_CACHE_TIMEOUT (3) 9 - CURLOPT_DNS_LOCAL_IP4 (3) 10 - CURLOPT_DNS_LOCAL_IP6 (3) 11 Protocol: 12 - All 13 Added-in: 7.24.0 14 --- 15 16 # NAME 17 18 CURLOPT_DNS_SERVERS - DNS servers to use 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char *servers); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a char pointer that is the list of DNS servers to be used instead of the 31 system default. The format of the dns servers option is: 32 33 host[:port][,host[:port]]... 34 35 For example: 36 37 192.168.1.100,192.168.1.101,3.4.5.6 38 39 The application does not have to keep the string around after setting this 40 option. 41 42 Using this option multiple times makes the last set string override the 43 previous ones. Set it to NULL to disable its use again. 44 45 # DEFAULT 46 47 NULL 48 49 # %PROTOCOLS% 50 51 # EXAMPLE 52 53 ~~~c 54 int main(void) 55 { 56 CURL *curl = curl_easy_init(); 57 if(curl) { 58 CURLcode res; 59 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 60 curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, 61 "192.168.1.100:53,192.168.1.101"); 62 res = curl_easy_perform(curl); 63 curl_easy_cleanup(curl); 64 } 65 } 66 ~~~ 67 68 # NOTES 69 70 This option requires that libcurl was built with a resolver backend that 71 supports this operation. The c-ares backend is the only such one. 72 73 # %AVAILABILITY% 74 75 # RETURN VALUE 76 77 curl_easy_setopt(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).