I have 3 network interface plug in my pc (windows). I just wonder is there a easy way to make a http request from specific interface ?
I try curl but it seem not support windows.
Description here : https://curl.se/libcurl/c/CURLOPT_INTERFACE.html
libcurl does not support using network interface names for this option on Windows.
Here is my network details :
Ethernet adapter NETW 001:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::8a7:9368:bb58:1883
IPv4 Address. . . . . . . . . . . : 192.168.5.252
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.5.1
Ethernet adapter NETW 002:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::e4e0:bc83:3e56:8de0
IPv4 Address. . . . . . . . . . . : 192.168.78.252
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.78.1
Ethernet adapter NETW 003:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::f0e7:c451:335:8587
IPv4 Address. . . . . . . . . . . : 192.168.1.252
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
CodePudding user response:
It is not clear what stops you from using the specific interface by its IPv4 Address. The same manual:
Pass a char * as parameter. This sets the interface name to use as outgoing network interface. The name can be an interface name, an IP address, or a host name.
If the parameter starts with "host!" it is treated as either an IP address or a hostname.
#if 1
curl_easy_setopt(curl, CURLOPT_INTERFACE, "192.168.78.252");
#else
curl_easy_setopt(curl, CURLOPT_INTERFACE, "host!192.168.78.252");
#endif