Re: How to limit source IP in PHP
| From: | Jim Lucas | Date: | Thu, 13 Sep 2012 22:09:29 +0000 |
| Subject: | Re: How to limit source IP in PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319070@lists.php.net to get a copy of this message | ||
On 09/13/2012 12:55 PM, Tonix (Antonio Nati) wrote:
Il 13/09/2012 21:41, Jim Lucas ha scritto:My experience has always been, with Apache and lighttpd at least, that the response comes from the IP:PORT that the request was made to. So, if I connect to http://10.10.10.10/ Then the response is going to come from PORT 80. You might want to run a little trafshow on your server to see how the traffic behaves. I have a number of web servers that I run, all with either apache or lighttpd, and they all behave this way. Here is the output of my http request from my office to my server:On 09/13/2012 12:28 PM, Tonix (Antonio Nati) wrote:And so? There is no relation between the call received from Apache (which is not passed to PHP), and any connection PHP may open later.You are speaking about incoming connections, I suppose. I'm speaking about connections started from within PHP.Which is a response to the incoming connection.
From Address To Address Pro Bytes CPS======================================================================
66.39.178.2..58479 66.39.167.51..80 tcp 725 12 66.39.167.51..80 66.39.178.2..58479 tcp 2720 66.39.178.2..52515 66.39.167.51..80 tcp 1303 66.39.178.2..54506 66.39.167.51..80 tcp 696 66.39.178.2..62658 66.39.167.51..80 tcp 700 66.39.178.2..65382 66.39.167.51..80 tcp 700 66.39.167.51..80 66.39.178.2..52515 tcp 545 66.39.178.2..50794 66.39.167.51..80 tcp 700 66.39.178.2..65015 66.39.167.51..80 tcp 711 66.39.167.51..80 66.39.178.2..54506 tcp 305 66.39.167.51..80 66.39.178.2..62658 tcp 305 66.39.167.51..80 66.39.178.2..65382 tcp 357 66.39.167.51..80 66.39.178.2..50794 tcp 357 66.39.167.51..80 66.39.178.2..65015 tcp 357This is running Apache.
But this is a secondary connection (that you open in process) and has nothing to do with the request connection to the server from the client.Unless you are talking about PHP being ran from cron or the CLI. if you are talking about YOU running a PHP script as a daemon, then yes, you have the ability to BIND to an IP address. I do this in a few scripts/daemons of mine. I use the stream_* functions for this. But, if you are talking about calling fopen() from the CLI and have it "bind" to a specific IP when connecting out, that is more of a OS specific option. You will need to find out how to run a php script and have it "bind" to a given IP (or interface) when it connects to the WWW.When apache starts a php script, the script can open a socket towards another end-point, asking to bind to any local address as source address.
Period. Regards, Tonino-- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/