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