If you look at the CURLOPT_INTERFACE manual you will find that setting it to
NULL to will tell cURL to use whatever the TCP stack finds suitable (default behavior), however that isn’t the case in PHP.
If you set
curl_setopt like this:
curl_setopt( $ch, CURLOPT_INTERFACE, null );
You will wind up with
Error Code: 45 (Could not resolve host)
That’s because PHP does not support it. According to to curl-setopt manual:
CURLOPT_INTERFACE = The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.
CURLOPT_INTERFACE only accepts valid string in PHP. It does not accept
"" (empty string).
Set it to
curl_setopt( $ch, CURLOPT_INTERFACE, '0.0.0.0' );
Now, cURL will use whatever the TCP stack finds suitable (default behavior).
0.0.0.0 ? – Read https://superuser.com/a/949429/689060
All the credits goes to /u/ta22175 for giving me the solution.