It is not possible any external server access the "local IP" (IP of an internal network), I got to comment something about this here:
The most that an external server (regardless of the language you use) will achieve is the ISP IP (Internet Service Provider - Internet Service Provider), ie if 100 computers share the same "internet" all will have the "same IP" if use $_SERVER["REMOTE_ADDR"]
, because in fact the IP is the "connection".
There is no practical way around this, the example they cited in the comments does not work "natively":
$_SERVER['HTTP_X_REAL_IP'];
It is not a PHP variable but a variable generated by the headers of a "client" (browser, bot, etc.) via http, for example:
GET /pagina.php HTTP/1.1
User-Agent: MyBotFooBar1.0
X-Real-Ip: 10.0.0.105
That is all "variables" that start with HTTP_
are generated from the headers and this is not a safe way to verify authenticity, ie is easily riggable, since the headers can be easily manipulated.
Rarely will any browser send this the header X-Real-Ip
, you would have to configure them to do this using an add-on/extension or a "proxy", a very large job that may not be worth the effort.
If your goal is to use this for some "type of authentication" recommend to think of measures such as a mobile app with token (or something similar) and dispense with the use of Ips.
Note:
The tip about the ipconfig
only works if PHP is on the machine you want to get the address from:
exec('ipconfig', $array);
Using other commands will not work either, such as arp
, this because PHP would need to be on the same local network as computers, which I believe is not its goal.
i use 5.2.17 and it works. Put in your code phpinfo(); and see all the information in PHP Variables
– user60252
$_SERVER['HTTP_X_REAL_IP'];
– user60252
See this: http://answall.com/questions/143004/print-de-array-php/143010#143010
– Inkeliz