1CURLOPT_INTERFACE(3) curl_easy_setopt options CURLOPT_INTERFACE(3)
2
3
4
6 CURLOPT_INTERFACE - source interface for outgoing traffic
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
12
14 Pass a char * as parameter. This sets the interface name to use as out‐
15 going network interface. The name can be an interface name, an IP ad‐
16 dress, or a host name.
17
18 If the parameter starts with "if!" then it is treated as only as inter‐
19 face name and no attempt will ever be named to do treat it as an IP ad‐
20 dress or to do name resolution on it. If the parameter starts with
21 "host!" it is treated as either an IP address or a hostname. Hostnames
22 are resolved synchronously. Using the if! format is highly recommended
23 when using the multi interfaces to avoid allowing the code to block.
24 If "if!" is specified but the parameter does not match an existing in‐
25 terface, CURLE_INTERFACE_FAILED is returned from the libcurl function
26 used to perform the transfer.
27
28 libcurl does not support using network interface names for this option
29 on Windows.
30
31 The application does not have to keep the string around after setting
32 this option.
33
35 NULL, use whatever the TCP stack finds suitable
36
38 All
39
41 CURL *curl = curl_easy_init();
42 if(curl) {
43 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
44
45 curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
46
47 ret = curl_easy_perform(curl);
48
49 curl_easy_cleanup(curl);
50 }
51
53 The "if!" and "host!" syntax was added in 7.24.0.
54
56 Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insuf‐
57 ficient heap space.
58
60 CURLOPT_SOCKOPTFUNCTION(3), CURLOPT_TCP_NODELAY(3),
61
62
63
64libcurl 7.85.0 May 17, 2022 CURLOPT_INTERFACE(3)