Using CURLOPT_CONNECT_TO with an IPv6 address
There was a bug in libcurl (before 7.58.0) which made it take IPv6 addresses and attempt to use them for CURLOPT_CONNECT_TO, even if it was built without support for IPv6!
This was addressed in curl 7.58.0 and from then on it makes libcurl return an error if this is attempted!
Assign specific IPv6 address of subnet to cURL
cURL cannot bind to 2a01:4f8:XXXX:YYYY::3 because 2a01:4f8:XXXX:YYYY::3 is not an IP local address assigned to any interface. Hosts can only receive packets on addresses that are assigned to them, and, accordingly, you can only bind to those addresses.
As you described, if you do add 2a01:4f8:XXXX:YYYY::3 as an address on the interface using ip addr add
, it works. That is to be expected.
I don't know of a way to assign a large group of addresses to the local system without having to add them one by one. There is a trick but it only works for some operating systems (perhaps only Linux) and only for IPv4 and only for the loopback interface.
PHP curl failing to resolve IPv6-only URL
Your expectations of CURLOPT_IPRESOLVE
are correct, that is indeed what it is supposed to do. However you seem to have used a wrong constant for the value. From the manual:
CURLOPT_IPRESOLVE: Allows an application to select what kind of IP
addresses to use when resolving host names. This is only interesting
when using host names that resolve addresses using more than one
version of IP, possible values are CURL_IPRESOLVE_WHATEVER,
CURL_IPRESOLVE_V4, CURL_IPRESOLVE_V6, by default
CURL_IPRESOLVE_WHATEVER.
I can't find the constant you use (CURL_VERSION_IPV6
) in the manual, so IIRC then PHP will interpret it as the string "CURL_VERSION_IPV6"
which won't work.
Related Topics
How to Get Command History by Cursor Key in Linux Tclsh
Installing Gcc from Source on Alpine
Check If All Lines from One File Are Present Somewhere in Another File
Kafka Console Consumer with Kerberos Authentication
How to Get Yesterday and Day Before Yesterday in Linux
How Do Shared Libraries Work in a Mixed 64Bit/32Bit System
Can Not Connect to Google Compute Engine via Ssh
How to Connect to Server: Postgresql on Ubuntu in Windows Subsystem for Linux
Deploying War in Jboss 7.0.1 Through Commandline
Linux Append Console Output to a Logfile
Set Environment Variables in an Aws Instance
How to Make Sure Only One Instance of a Bash Script Is Running at a Time
Linux: Checking If a Socket/Pipe Is Broken Without Doing a Read()/Write()
Yocto Bitbake Script Not Displaying Echo Statement
Using "And" in Bash While Loop