CURLOPT_INTERFACE.3 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_INTERFACE 3 "17 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_INTERFACE \- source interface for outgoing traffic
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a char * as parameter. This sets the \fIinterface\fP name to use as
  35. outgoing network interface. The name can be an interface name, an IP address,
  36. or a host name.
  37. If the parameter starts with "if!" then it is treated as only as interface
  38. name and no attempt will ever be named to do treat it as an IP address or to
  39. do name resolution on it. If the parameter starts with \&"host!" it is treated
  40. as either an IP address or a hostname.
  41. If "if!" is specified but the parameter does not match an existing interface,
  42. \fICURLE_INTERFACE_FAILED\fP is returned from the libcurl function used to
  43. perform the transfer.
  44. libcurl does not support using network interface names for this option on
  45. Windows.
  46. We strongly advise against specifying the interface with a hostname, as it
  47. causes libcurl to do a blocking name resolve call to retrieve the IP
  48. address. That name resolve operation will \fBnot\fP use DNS-over-HTTPS even if
  49. \fICURLOPT_DOH_URL(3)\fP is set.
  50. The application does not have to keep the string around after setting this
  51. option.
  52. .SH DEFAULT
  53. NULL, use whatever the TCP stack finds suitable
  54. .SH PROTOCOLS
  55. All
  56. .SH EXAMPLE
  57. .nf
  58. CURL *curl = curl_easy_init();
  59. if(curl) {
  60. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  61. curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
  62. ret = curl_easy_perform(curl);
  63. curl_easy_cleanup(curl);
  64. }
  65. .fi
  66. .SH AVAILABILITY
  67. The "if!" and "host!" syntax was added in 7.24.0.
  68. .SH RETURN VALUE
  69. Returns CURLE_OK on success or
  70. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  71. .SH "SEE ALSO"
  72. .BR CURLOPT_SOCKOPTFUNCTION "(3), " CURLOPT_TCP_NODELAY "(3), "