Is it possible to retrieve IP behind NAT in PHP?
I am using $_SERVER["REMOTE_ADDR"]
for getting IP address of the client. It's not giving exact IP address of the client which is in behind NAT.
Using getenv() function: To get the IP Address,we use getenv(“REMOTE_ADDR”) command. The getenv() function in PHP is used for retrieval of values of an environment variable in PHP.
Go to www.whatismyip.com. If the IP it shows is different from the IP of your NIC, you're behind a NAT. If by NAT you mean any NAT including a WIFI router for example click the windows button, type cmd, click on command prompt, type in ipconfig and press enter, see what it says to the right of "IPv4 Address".
On the command prompt screen, type the words “ping host address,” where “host address” equals the address of the website you're looking to trace, and hit Enter. For example, if you want to find the IP address of Facebook, you would type the words “ping www.facebook.com” and then press enter.
It is not possible to get the IP behind a NAT using HTTP and php.
Nope, not possible. NAT means Network Address Translation - the IP address of the packets is rewritten at the NAT device, so the public IP address is the only one, as far as your server knows.
However, you can employ some tricks - such as checking for the internal IP address using a Java Applet. See this: Get the correct local IP address from java applet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With