Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURL --interface not working: "Couldn't bind to ..." error

Tags:

curl

I'm trying to use curl with another IP address from the ones available in the server but I get this error:

curl --interface 41.141.41.23 http://www.google.com

curl: (45) Couldn't bind to 41.141.41.23 (its just an example address)

It only lets me do it with the main one and only by the interface name:

curl --interface eth0 http://www.google.com

I'm using:

Ubuntu 12.04

curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

like image 584
jonfer Avatar asked Oct 16 '25 00:10

jonfer


1 Answers

Looks like there is a bug in Curl when using --interface if the domain requested is using both ipv4 and ipv6 instead of just ipv4 you have to add --ipv4 to work.

So thats the case with www.google.com, so to make it work would be:

curl --interface 41.141.41.23 --ipv4 http://www.google.com
like image 195
jonfer Avatar answered Oct 17 '25 19:10

jonfer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!