It is not possible for any external server to access the "local IP" (IP of an internal network), I got to comment something about it here:
The maximum that an external server (regardless of the language it uses) will achieve is the IP of the Internet Service Provider (ISP), that is, if 100 computers share the same " internet "will all have the same" IP "if you use $_SERVER["REMOTE_ADDR"]
, because the IP is actually" 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
In other words, all "variables" that start with HTTP_
are generated from the headers and this is not a safe way to verify authenticity, since headers can be easily manipulated.
Rarely will any browser send this 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. p>
If your goal is to use this for some "authentication type" I recommend thinking of measures like a token-enabled mobile app (or something like that) / p>
Note:
The tip about ipconfig
only works if PHP is on the machine that wants to get the address:
exec('ipconfig', $array);
Using other commands will also not work, such as arp
, because PHP would need to be on the same local network as the computers, which I believe is not your goal.