CURLOPT_INTERFACE.3 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .\" generated by cd2nroff 0.1 from CURLOPT_INTERFACE.md
  2. .TH CURLOPT_INTERFACE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_INTERFACE \- source interface for outgoing traffic
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a char pointer as parameter. This sets the \fIinterface\fP name to use as
  12. outgoing network interface. The name can be an interface name, an IP address,
  13. or a hostname. If you prefer one of these, you can use the following special
  14. prefixes:
  15. * \fIif!<name>\fP \- Interface name
  16. * \fIhost!<name>\fP \- IP address or hostname
  17. * \fIifhost!<interface>!<host>\fP \- Interface name and IP address or hostname
  18. If \fIif!\fP or \fIifhost!\fP is specified but the parameter does not match an existing
  19. interface, \fICURLE_INTERFACE_FAILED\fP is returned from the libcurl function used
  20. to perform the transfer.
  21. libcurl does not support using network interface names for this option on
  22. Windows.
  23. We strongly advise against specifying the interface with a hostname, as it
  24. causes libcurl to do a blocking name resolve call to retrieve the IP
  25. address. That name resolve operation does \fBnot\fP use DNS\-over\-HTTPS even if
  26. \fICURLOPT_DOH_URL(3)\fP is set.
  27. The application does not have to keep the string around after setting this
  28. option.
  29. .SH DEFAULT
  30. NULL, use whatever the TCP stack finds suitable
  31. .SH PROTOCOLS
  32. This functionality affects all supported protocols
  33. .SH EXAMPLE
  34. .nf
  35. int main(void)
  36. {
  37. CURL *curl = curl_easy_init();
  38. if(curl) {
  39. CURLcode res;
  40. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  41. curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
  42. res = curl_easy_perform(curl);
  43. curl_easy_cleanup(curl);
  44. }
  45. }
  46. .fi
  47. .SH HISTORY
  48. The \fIif!\fP and \fIhost!\fP syntax was added in 7.24.0.
  49. The \fIifhost!\fP syntax was added in 8.9.0.
  50. .SH AVAILABILITY
  51. Added in curl 7.3
  52. .SH RETURN VALUE
  53. Returns CURLE_OK on success or
  54. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  55. .SH SEE ALSO
  56. .BR CURLOPT_LOCALPORT (3),
  57. .BR CURLOPT_SOCKOPTFUNCTION (3),
  58. .BR CURLOPT_TCP_NODELAY (3)