I want to rotate IP addresses for web-scraping, and here is my setup:
I have configured multiple IP addresses as below in my
/etc/network/interfaces
file:# The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 iface eth0 inet static address XX.XXX.XXX.146 netmask 255.255.255.248 network XX.XXX.XXX.144 broadcast XX.XXX.XXX.151 gateway XX.XXX.XXX.145 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 208.67.222.222 208.67.220.220 dns-search host.myhost.com auto eth0:1 iface eth0:1 inet static address XX.XXX.XXX.147 netmask 255.255.255.248 broadcast XX.XXX.XXX.151 network XX.XXX.XXX.144 auto eth0:2 iface eth0:2 inet static address XX.XXX.XXX.148 netmask 255.255.255.248 broadcast XX.XXX.XXX.151 network XX.XXX.XXX.144 auto eth0:3 iface eth0:3 inet static address XX.XXX.XXX.149 netmask 255.255.255.248 broadcast XX.XXX.XXX.151 network XX.XXX.XXX.144
Cloudflare DNS performs the round-robin to different IP addresses of my server.
However, when I use the following PHP script to check my external IP address, I get different values for
$_SERVER['SERVER_ADDR'];
but my external IP address remains same (as checked by the script below fromhttp://checkip.dyndns.com/
).<?php $externalContent = file_get_contents('http://checkip.dyndns.com/'); preg_match('/Current IP Address: ([\[\]:.[0-9a-fA-F]+)</', $externalContent, $m); $externalIp = $m[1]; echo $externalIp; echo '<br/>'; echo $_SERVER['SERVER_ADDR']; ?>
What am I missing here, I want to execute an external executable which should use different public IP addresses available on my server in rotation?