From owner-freebsd-net@FreeBSD.ORG Tue Dec 15 13:05:25 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53FF01065672 for ; Tue, 15 Dec 2009 13:05:25 +0000 (UTC) (envelope-from om-lists-bsd@omx.ch) Received: from ibox.insign.ch (ibox.insign.ch [195.134.143.207]) by mx1.freebsd.org (Postfix) with SMTP id A75958FC0A for ; Tue, 15 Dec 2009 13:05:24 +0000 (UTC) Received: (qmail 92556 invoked from network); 15 Dec 2009 12:37:20 -0000 Received: from [192.168.1.170] ([80.254.166.203]) by ibox.insign.ch ([195.134.143.207]) with ESMTP via TCP; 15 Dec 2009 12:37:20 -0000 From: Olivier Mueller To: freebsd-questions@freebsd.org, freebsd-net@freebsd.org Content-Type: text/plain Date: Tue, 15 Dec 2009 13:37:18 +0100 Message-Id: <1260880638.26162.26.camel@ompc.insign.local> Mime-Version: 1.0 X-Mailer: Evolution 2.24.1.1 Content-Transfer-Encoding: 7bit Cc: Subject: networking differences with php file_get_contents under 6.1 and 7.2 ? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2009 13:05:25 -0000 Hello, I just observed a strange thing on 2 servers with a very similar setup (apache config, php version/ini, virtual ip addresses, etc.) but under 2 different FreeBSD versions. I would like to understand if is related to the OS version and why. To test, I have a short php script which calls itselfs with file_get_contents() : under 6.1 the source IP is the one from apache virtual host, and under 7.2 it's the first interface from server : why this difference? Is it a new feature/change in 7.x, or a bug(fix)? If I do a request on an external server (like http://crazzy.se/get_ip.php ) it always return the main server IP. Only when I do the call locally and under 6.1 it's not the case... Under 6.1 I get this output (scroll down for the script): test1.example.com = virtual host under 10.0.0.239 main server ip = 10.0.0.210 ------------------------------------------------------------ Initial call: SERVER_ADDR: 10.0.0.239 REMOTE_ADDR: 10.0.0.12 calling... http://test1.example.com/iptest_om.php?recall=1 ------------------------------------------------------------ Call from self: SERVER_ADDR: 10.0.0.239 REMOTE_ADDR: 10.0.0.239 (client) <<<<====== ???? end ------------------------------------------------------------ end ifconfig: bce0: flags=8843 mtu 1500 options=3b inet6 fe80::218:feff:fe31:8ae4%bce0 prefixlen 64 scopeid 0x1 inet 10.0.0.210 netmask 0xffffff00 broadcast 10.0.0.255 inet 10.0.0.212 netmask 0xffffff00 broadcast 10.0.0.255 inet 10.0.0.239 netmask 0xffffff00 broadcast 10.0.0.255 and under 7.2: (test2.example.com = 10.0.0.122, main = .120) ------------------------------------------------------------ Initial call: SERVER_ADDR: 10.0.0.122 REMOTE_ADDR: 10.0.0.12 calling... http://test2.example.com/iptest_om.php?recall=1 ------------------------------------------------------------ Call from self: SERVER_ADDR: 10.0.0.122 REMOTE_ADDR: 10.0.0.120 (client) <<====== ok end ------------------------------------------------------------ end ifconfig: bce0: flags=8843 metric 0 mtu 1500 options=1bb ether 00:1f:29:06:9c:38 inet 10.0.0.120 netmask 0xffffff00 broadcast 10.0.0.255 inet 10.0.0.122 netmask 0xffffff00 broadcast 10.0.0.255 inet 10.0.0.123 netmask 0xffffff00 broadcast 10.0.0.255 test script: \n"; print "Initial call:
\n"; print "SERVER_ADDR: " . $_SERVER["SERVER_ADDR"] . "
\n"; print "REMOTE_ADDR: " . $_SERVER["REMOTE_ADDR"] . "
\n"; print "
\n"; $url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] . "?recall=1"; print "calling... $url
\n"; print "\n"; echo file_get_contents($url); print "\n"; print "
\n"; } if ($_GET["recall"] == 1) { print "
\n"; print "Call from self:
\n"; print "SERVER_ADDR: " . $_SERVER["SERVER_ADDR"] . "
\n"; print "REMOTE_ADDR: " . $_SERVER["REMOTE_ADDR"] . " (client)
\n"; print "
\n"; print "\n"; } print "end
\n"; ?> Thanks for any feedback & regards, Olivier