1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_INTERFACE 5Section: 3 6Source: libcurl 7Protocol: 8 - All 9See-also: 10 - CURLOPT_SOCKOPTFUNCTION (3) 11 - CURLOPT_TCP_NODELAY (3) 12 - CURLOPT_LOCALPORT (3) 13--- 14 15# NAME 16 17CURLOPT_INTERFACE - source interface for outgoing traffic 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface); 25~~~ 26 27# DESCRIPTION 28 29Pass a char pointer as parameter. This sets the *interface* name to use as 30outgoing network interface. The name can be an interface name, an IP address, 31or a hostname. 32 33If the parameter starts with "if!" then it is treated only as an interface 34name. If the parameter starts with "host!" it is treated as either an IP 35address or a hostname. 36 37If "if!" is specified but the parameter does not match an existing interface, 38*CURLE_INTERFACE_FAILED* is returned from the libcurl function used to perform 39the transfer. 40 41libcurl does not support using network interface names for this option on 42Windows. 43 44We strongly advise against specifying the interface with a hostname, as it 45causes libcurl to do a blocking name resolve call to retrieve the IP 46address. That name resolve operation does **not** use DNS-over-HTTPS even if 47CURLOPT_DOH_URL(3) is set. 48 49The application does not have to keep the string around after setting this 50option. 51 52# DEFAULT 53 54NULL, use whatever the TCP stack finds suitable 55 56# EXAMPLE 57 58~~~c 59int main(void) 60{ 61 CURL *curl = curl_easy_init(); 62 if(curl) { 63 CURLcode res; 64 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 65 66 curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0"); 67 68 res = curl_easy_perform(curl); 69 70 curl_easy_cleanup(curl); 71 } 72} 73~~~ 74 75# AVAILABILITY 76 77The "if!" and "host!" syntax was added in 7.24.0. 78 79# RETURN VALUE 80 81Returns CURLE_OK on success or 82CURLE_OUT_OF_MEMORY if there was insufficient heap space. 83