Link to home
Start Free TrialLog in
Avatar of Curtis Long
Curtis LongFlag for United States of America

asked on

$_SERVER['REMOTE_ADDR'] gives me local address of router

When accessing a website I have hosted at home through the external IP address, I try to keep track of users using their IP address among other things. However, when using the $_SERVER['REMOTE_ADDR'] variable to get the IP address, it returns 192.168.1.1 which is the internal IP address of my router. I am using the latest version of XAMPP. This does not do me any good when trying to prevent session hijacking by locking it to an IP address if all IP addresses are 192.168.1.1. Does anyone know a fix for this problem? And yes, the computer I am trying this one is on the same LAN, but I try to access it from the external IP address, so I am a little confused. Any help would be greatly appreciated

Thanks
Avatar of Tasmant
Tasmant
Flag of France image

seems your router translate your IP ... NAT it, instead of forward it.
you say you use a computer to test on the same subnet as your router and server. could you explain more how you can expect go external and go back after ?
>Does anyone know a fix for this problem? And yes, the computer I am trying this one is on the same >LAN, but I try to access it from the external IP address, so I am a little confused. Any help would be >greatly appreciated

This is the functionality of NAT, and why NAT breaks the end to end model. Of course, this is if in fact your are natting between subnets. You will find that if you try using a host from the outside interface (The Internet) it will work.

Billy
ASKER CERTIFIED SOLUTION
Avatar of Tasmant
Tasmant
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Curtis Long

ASKER

Really clear explanation on why this happens. Thanks
You could have split up the points!