1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_DNS_SERVERS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_DNS_CACHE_TIMEOUT (3) 9 - CURLOPT_DNS_LOCAL_IP4 (3) 10 - CURLOPT_DNS_LOCAL_IP6 (3) 11Protocol: 12 - All 13--- 14 15# NAME 16 17CURLOPT_DNS_SERVERS - DNS servers to use 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char *servers); 25~~~ 26 27# DESCRIPTION 28 29Pass a char pointer that is the list of DNS servers to be used instead of the 30system default. The format of the dns servers option is: 31 32host[:port][,host[:port]]... 33 34For example: 35 36192.168.1.100,192.168.1.101,3.4.5.6 37 38The application does not have to keep the string around after setting this 39option. 40 41# DEFAULT 42 43NULL - use system default 44 45# EXAMPLE 46 47~~~c 48int main(void) 49{ 50 CURL *curl = curl_easy_init(); 51 if(curl) { 52 CURLcode res; 53 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 54 curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, 55 "192.168.1.100:53,192.168.1.101"); 56 res = curl_easy_perform(curl); 57 curl_easy_cleanup(curl); 58 } 59} 60~~~ 61 62# AVAILABILITY 63 64This option requires that libcurl was built with a resolver backend that 65supports this operation. The c-ares backend is the only such one. 66 67Added in 7.24.0 68 69# RETURN VALUE 70 71Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, 72CURLE_NOT_BUILT_IN if support was disabled at compile-time, 73CURLE_BAD_FUNCTION_ARGUMENT when given an invalid server list, or 74CURLE_OUT_OF_MEMORY if there was insufficient heap space. 75