By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

how to get WAN IP with PHP Code

P: 99
Dear All,
I faced a problem while making a login report. When the user visit the site, I want to get WAN IP and System IP. The problem is that i can get the system ip with the code $ip=$_SERVER['REMOTE_ADDR']; but not able to find the code to get WAN IP. Please help me so that I can get the WAN IP of the system.
Thanking you all in advance for your kind support.


Robindra Singha
Sep 3 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,058

As I understand it, on a typical LAN setup, where the entire LAN is connected to the internet via a router, each computer on the LAN would share a "external", WAN IP (assigned to the router), but each of them would have a "internal", LAN IP (typically 192.168.*.*).

In that scenario, all external requests by any computer on that LAN would appear to come from the same WAN IP. The router alone would be aware of which computer on the LAN the request belongs to, so there would be no way for your PHP to detect the LAN IP, but only the WAN IP (via the $_SERVER['REMOTE_ADDR'] element)

If the request is internal (like say to a HTTP server on the same LAN), the $_SERVER['REMOTE_ADDR'] element would retain the LAN IP of the computer that made the request.

In short, the server only knows the IP of the device that sent the request, regardless of whether that IP belongs to a LAN, WAN or any other sort of network.
Sep 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.