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