-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Closed
Description
Hello,
Error
An error curl: (45) bind failed with errno 22: Invalid argument
occurs whenever we specify IPv4 from local interface as a source address trying to connect to a site which have both IPv4 and IPv6.
Steps to reproduce
Pick up a domain which resolves both to IPv4 and IPv6:
# host canhazip.com
canhazip.com has address 104.16.222.38
canhazip.com has address 104.16.223.38
canhazip.com has IPv6 address 2606:4700::6810:de26
canhazip.com has IPv6 address 2606:4700::6810:df26
The request:
# curl --interface 1.2.3.4 https://canhazip.com/
curl: (45) bind failed with errno 22: Invalid argument
can be fixed with -4
flag:
# curl --interface 1.2.3.4 -4 https://canhazip.com/
1.2.3.4
OS
Tested with CentOS 7:
- default version cURL:
curl-7.29.0-51.el7.x86_64
- and from a git repository:
curl 7.65.1-DEV (x86_64-unknown-linux-gnu) libcurl/7.65.1-DEV OpenSSL/1.0.2k-fips zlib/1.2.7
Results are the same.
Expected behavior:
Whenever a source IPv4 is specified cURL should auto add -4 flag, i.e.:
curl_easy_setopt(easyhandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
The same with IPv6, whenever a source IPv6 is specified cURL should auto add -6 flag, i.e.
curl_easy_setopt(easyhandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
Regards,
Alex.