1CURLOPT_INTERFACE(3)                libcurl               CURLOPT_INTERFACE(3)
2
3
4

NAME

6       CURLOPT_INTERFACE - source interface for outgoing traffic
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
12

DESCRIPTION

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.
22
23       If "if!" is specified but the parameter does not match an existing  in‐
24       terface,  CURLE_INTERFACE_FAILED  is returned from the libcurl function
25       used to perform the transfer.
26
27       libcurl does not support using network interface names for this  option
28       on Windows.
29
30       We strongly advise against specifying the interface with a hostname, as
31       it causes libcurl to do a blocking name resolve call to retrieve the IP
32       address.  That  name resolve operation will not use DNS-over-HTTPS even
33       if CURLOPT_DOH_URL(3) is set.
34
35       The application does not have to keep the string around  after  setting
36       this option.
37

DEFAULT

39       NULL, use whatever the TCP stack finds suitable
40

PROTOCOLS

42       All
43

EXAMPLE

45       CURL *curl = curl_easy_init();
46       if(curl) {
47         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
48
49         curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
50
51         ret = curl_easy_perform(curl);
52
53         curl_easy_cleanup(curl);
54       }
55

AVAILABILITY

57       The "if!" and "host!" syntax was added in 7.24.0.
58

RETURN VALUE

60       Returns  CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insuf‐
61       ficient heap space.
62

SEE ALSO

64       CURLOPT_SOCKOPTFUNCTION(3), CURLOPT_TCP_NODELAY(3),
65
66
67
68ibcurl 8.2.1                    April 26, 2023            CURLOPT_INTERFACE(3)
Impressum