Reputation: 11327
Ignoring other possiblities such as Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
, does Request.ServerVariables["REMOTE_ADDR"]
gives me the "principal" IP of the client?
I'm talking about the IP that made the actual TCP connection.
Will ServerVariables["REMOTE_ADDR"]
always be the "real" IP address of the remote endpoint?
Just to clarify: Even if it's a proxy who made the real TCP connection I'd like have its IP, and not a forwarded one.
Upvotes: 0
Views: 1676
Reputation: 23236
Yes, except if its been through a NAT firewall. A NAT firewalled address would be masquerading many 192.168.x.x or any other private subnet behind a public IP address. So you'd be looking at the IP address of the NAT firewall (i.e. a Linksys Router or what have you).
Be warned that many cell phone carriers have HUGE NAT networks so they always look like they are coming from one or two public IP addresses.
Upvotes: 2
Reputation: 40160
The REMOTE_ADDR
variable will be the IP of the system that directly connected to your web server to request the URL; so it would be the forward-most proxy server, if there is a proxy server.
Upvotes: 1