使用此代码:
在服务器 AI 上有这个:
$handle = fopen('http://www.server_b.com/get_ip.php', 'r'); //This is just a PHP file that echoes the REMOTE_ADDR
echo "IP looks like ".fread($handle, '100000')." to external server.\n";
fclose($handle);
echo "IP looks like ".$_SERVER['SERVER_ADDR']." to this server.";
在服务器 BI 上有这个:
echo $_SERVER['REMOTE_ADDR'];
我从服务器 A 得到以下输出:
IP looks like xxx.xxx.223.90 to external server. //xxx.xxx on both lines are the same
IP looks like xxx.xxx.223.94 to this server.
为什么我得到两个不同的 IP?请注意,我们确实拥有 .90-.94 的 IP 范围