I have a server with two different IPs. I need to send odd curl requests from first IP, and even from the second one. How can I select outgoing IP address?
My PHP script is something like this:
$curlh = curl_init($url); curl_setopt($curlh, CURLOPT_USERAGENT, $uagent); curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curlh);
How can I do so?
yes you can request normally, but do not change url as a file in local.
You may want to try setting the CURLOPT_INTERFACE
option:
curl_setopt($curlh, CURLOPT_INTERFACE, "xxx.xxx.xxx.xxx");
CURLOPT_INTERFACE: The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.
From: php Manual: curl_setopt
EDIT: Fixing example, as @Michael Hart pointed out pointed out in the other answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With