-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--interface and CURLOPT_INTERFACE works different for Ip Address and Interface #13613
Comments
I still don't think this is a "bug" per se, but an area for possible improvement. You do ask for a bind to an IP but are saying you want I'm not 100% convinced that is what this option guarantees or says it should do. If you want to bind to the interface device, why not bind to the interface name? |
if I use the Ip address, which fuction is used to bind the socket on it? |
I think the reason is that when I use an IP address, curl will use bind to bind the socket to the specified IP. In this case, the operating system just makes sure that the source IP will be the IP address I set. This means that the router rule is not affected. If I specify the interface, the operating system will make sure that the package will be sent through this interface and ignore the unmatched rules. |
In the curl documentation, it says CURLOPT_INTERFACE will "set the interface name to use as the outgoing network interface. The name can be an interface name, an IP address, or a hostname". So, I think there should be no difference whether I pass an IP address or an interface name. |
|
I did this
Both of the commands should work
curl -k --interface ens3 https://172.30.0.35
curl -k --interface "172.30.3.145" https://172.30.0.35
I expected the following
only the (1) is able to
ens3 and 172.30.3.145 are the same IP address(I checked by using ifconfig)
This is similar to the issue 11599 and I know that issue was marked as no bug.
I read the source code,and curl uses SO_BINDTODEVICE to bind on the interface. So I think that if I input the IP address, there must be somewhere to tranfers the IP address to the interface. The function may not work properly on some Linux.
curl/libcurl version
7.68.0
operating system
Linux ubuntu
The text was updated successfully, but these errors were encountered: