0

I'm using cron to run everyday script, which has to run 5 php-cli processes. I need them to use separate interfaces.

I have 5 devices, eth0, eth1, eth2, eth3, eth4.

How can I call php to make sure it uses only one of them?

It's running on Centos 6.6

2
  • What do you mean by using interface? What is your process/script doing?
    – Khaled
    May 28, 2015 at 12:31
  • My script downloads data using curl (called as class from PHP, not as command). When I run this script, it always uses eth0 to connect. I need something like: php script.php --interface=eth0 && php script.php --interface=eth1 etc.
    – michail_w
    May 28, 2015 at 12:34

2 Answers 2

3

Here is a related post from stackoverflow.

You need to use function call like the following to set interface name or IP address.

curl_setopt($curlh, CURLOPT_INTERFACE, "xxx.xxx.xxx.xxx");
0
2

Why do you want to use a different interface in each case? Unless you are benchmarking the interfaces and for some reason want to do that in php, then there is probably a better solution.

libcurl does implement this sort of functionality, but I'm not sure about php's binding for it. If it's not there, you could just use the curl command directly via a shell call. From the man page:

   --interface <name>
          Perform an operation using a specified interface. You can  enter
          interface  name,  IP address or host name. An example could look
          like:

           curl --interface eth0:1 http://www.netscape.com/

(Wow. netscape.com, eh? Noone's gone over that man page in a while).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .