File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to get internal LAN IP Address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get internal LAN IP Address" Watch "How to get internal LAN IP Address" New topic
Author

How to get internal LAN IP Address

Neir Kate
Greenhorn

Joined: Jan 24, 2007
Posts: 7
Currently using HttpServletRequest, I can get the IP address of the client that sent the request over the internet, by calling getRemoteAddr() method. But, I also need the client's IP address in its own Local Area Netwokk. Does anyone know how to get the client's internal LAN IP Address?? Is this possible ?

Please help, it's urgent ^_^

Thanks in advance
Kate
Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
It sounds like the clients lan is using NAT (Network Address Translation). From what I know about NAT is that it is doing it's job so that you cannot see their internal IP. If That doesn't sound right, please someone speak up.

Best


Jimmy Die
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

When I connect to your application from where I am now, you can see the IP address of our proxy server, which is a public IP address starting with 204, I think. But my private address in our LAN is 10.20. something, and you can't see that. This is as it should be.

Why do you think you need to see private IP addresses? If you have a design that relies on that, then there's something wrong with it and it needs to be fixed. Would you like to explain the problem a little more?
Neir Kate
Greenhorn

Joined: Jan 24, 2007
Posts: 7
Currently, when the branch of the company login to the system, we keep track of the 'action' and IP address, but beside the IP address that we obtain from the NAT, we also want to keep track of the local IP in LAN, so that we know directly, which computer access the system.

That's why I need to know the private IP addresses.

Thanks, best regards,
Neir Kate
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
If you need to actually know which machine logged onto the system, then you should be using MAC Addresses and not IP Addresses. A MAC Address can only be changed through a hardware modification, whereas an IP Address can be changed at any time (and many times, at least through DHCP, is changed dynamically at boot). But in either case, you will need to modify your login system to pass this information along, you cannot receive it remotely. And then keep in mind, that this info could be spoofed if anyone attempts to access the system through something other than your login process.
Neir Kate
Greenhorn

Joined: Jan 24, 2007
Posts: 7
Dear sir, thank you for your quick reply.

I'm interested in your solution about passing the information of the client along while doing the login process. But could you help me about what information that i could use ? The application is web based. Is it possible for my login page to look for the machine's mac address ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Unfortunately, I think the only way to get a client machine's NAT'ed IP address is to do it cooperatively. Your client software has to do it, and pass it as part of the service request.

The router (protecting the private network) generally does a very good job at it. And will not even tell you it is doing network address translation for other machines. In fact, besides monitoring usage patterns, it should be impossible for you to even tell there is a private network behind it.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
No, as Mr.Wong pointed out, the client side of your login would have to collect the info and pass it along. This has a lot of problems in a web environment as you would have to use something along the lines of an Applet or JavaScript to attempt to gather this information and there are many ways in which the user can disable this sort of access to their system (and most of them are, now adays, active per default). So you would need the user to actively "open" these security holes on their system, and I don't think this would be appreciated. It would also be, as I believe I mentioned before, easily spoofable which would, again, make the information unreliable. (Which everything gathered through a browser on a client through either an Applet or JavaScript is unreliable.)
 
 
subject: How to get internal LAN IP Address