If my server has multiple IP addresses, how can I run a script using each of the IP addresses?

Say my server has 10 IP addresses.

I would like to run the same PHP script 10 times, but use a different IP address each time. PHP script will have access to the Internet.

Is something like this possible? (each time using different IP addresses)

If so, can you point me in the right direction to do this?

Thanks.

+5
source share
1 answer

You can choose which interface you are communicating with:

$options = array( 'socket' => array( 'bindto' => '192.168.0.12:0', ), ); $context = stream_context_create($options); /* Sends an http request to www.example.com through local interface 192.168.0.12:0 */ $fp = fopen('http://www.example.com', 'r', false, $context); fpassthru($fp); fclose($fp); 

http://php.net/manual/en/function.stream-context-create.php

+4
source

Source: https://habr.com/ru/post/1205715/


All Articles