3

I'm trying to obtain the client's IP on a http request to a page hosted on iis.

I've looked into:

1) http://forums.asp.net/t/1780050.aspx/1

2) Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?

3) How to get a user's client IP address in ASP.NET?

4) Client IP using C#

As everyone said rightly, there is no fool proof way to get the client IP since the client can either be behind NAT or it can forge the IP address.

However, i tried REMOTE_ADDR, HTTP_X_FORWARDED_FOR and UserHostAddress. They all are returning the server's IP instead of the client (the server is on a different machine than the client) i.e. either 127.0.0.1 or the server's LAN IP (192.168.xxx.xxx). I was expecting the correct response from HTTP_X_FORWARDED_FOR as it is immune to a proxy server.

The puzzling thing is that when i host the page on the same machine as the client i.e. server is on localhost, i'm able to get the client ip (which is obviously equal to the server ip)

Is there any setting in IIS that needs to be configured to get this working? or is it some other problem within the intranet?

Community
  • 1
  • 1
user720694
  • 2,035
  • 6
  • 35
  • 57

0 Answers0