tags:

views:

320

answers:

1

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?

P.S. sorry if my English isn't good.

+3  A: 

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

Daniel Vassallo