• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Client IP address

 
kiran nyala
Ranch Hand
Posts: 55
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to track the client IP address from where user requested to my application.

I tried following:



In which InetAddress is giving my local machine IP when i run my application in localhost, but I mapped localhost:8080 with IIS server then InetAddress not giving exact IP address.
How can we resolve this?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Approach #7 would be the right one if the servlet container would be handling requests directly. But since they're usually behind a web server (like Apache or IIS), #2 is the way to go. If that header is not set, talk to whoever set up the IIS - it may need to have that feature enabled.
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My IP address is 192.168.10.5

In case you missed it, that's one of the private non-unique IP addresses that cannot be targeted from other locations on the Internet. The actual source IP address you'd see on an open Internet server would be the same IP address as every other computer on my LAN, because I'm using NAT.

That's even before you get into the proxying on the server side.

In short, IP addresses are a very poor way to identify or secure clients for web applications. About the only time they do what you want is if you intend to restrict access to a limited range of fixed addresses or are running a VPN tunnel.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!