Question

I have a Linux server with multiple ips (so, multiple eth0, eth0:0, eth0:1 etc). The script I'm trying to start is a php CLI script which is downloading stuff from an another server API, and I would like to change the IP based on different parameters. Once the script is started, I don't need anymore to change the ip OF THAT SPECIFIC script until his end.

Do you have any clue if it is possible to achieve it? My other solution was to install Xen or OpenVZ and create N different VPS per each IP, but as you can see is definitely a PITA :-)

Was it helpful?

Solution

You don't specify how you connect to the other server, but with sockets you can try socket_bind.

EDIT: With curl you can try curl_setopt. CURLOPT_INTERFACE The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.

OTHER TIPS

I know how to do it in C - you use bind() on your socket before you call connect(), and you bind to the IP address assigned to the desired interface, passing 0 for port. I don't know how to do it in PHP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top