Get External IP

  • Thread starter Thread starter Marc Rivait
  • Start date Start date
M

Marc Rivait

I have been struggling this one. As part of a application we want to
control IP addresses which come to our site.

On the web page we get the IP of the client computer using
Request.UserHostAddress(). However, if a user is coming to us from behind a
NAT, all we get is the internally assigned IP. We need to see the external
IP. I have not been able to find a method for getting this.

Thanks,
Marc.
 
You won't, not with a server technology at least. If they are coming through
some sort of VPN/etc and getting a NAT then that's what you'll get really.
Same thing if people are behind a proxy, you may get ONE IP for an entire
company.
 
Actually I think you have it backwards, NAT takes the internal ip and rewrites the packet with the external ip, if your visitors are hitting your site with an internal IP, they never had an external ip to begin with, and there would be no way of getting it unless you reroute traffic.

It's probably much easier and more secure to control IP access at IIS rather than in your asp.net application., you should be able to make it so only certain IP's can access your site.
 
Back
Top