Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a different server IP with PHP/cURL?

Tags:

php

curl

ip

I have a server with different IPs assigned, how can I specifiy a different IP to be used by cURL?

like image 743
plz Avatar asked Sep 18 '10 13:09

plz


1 Answers

You will have to use the CURLOPT_INTERFACE option:

The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.

It can be used in the following manner:

curl_setopt($ch, CURLOPT_INTERFACE, "XXX.XXX.XXX.XXX");

This ofcourse, only accepts IPs and hostnames from your local machine.

like image 62
Russell Dias Avatar answered Nov 17 '22 21:11

Russell Dias