Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

RMI get client IP Address

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guys, i need to get the client IP address, that is connecting to my Server. What I found, was to use the method RemoteServer.getClientHost().
But for sure is retriving the Server IP address.
If I run the RemoteServer.getClientHost(), in the client side, i get the error: java.rmi.server.ServerNotActiveException: not in a remote call.
There is a way to get the Client ip address?

thank you
 
Saloon Keeper
Posts: 22992
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Bruno!

There's little point in trying to obtain the client's IP address. Thanks to network address translation my machine's actual IP address might be 192.168.1.113 but servers will see me as 96.90.14.153.

So If you're planning to use the client's IP for authentication or authorization, don't bother. For RMI, it's better to provide an API method that will return a token when passed valid user credentials and pass that token back to the server on subsequent RMI calls.

And use a secure transport for the RMI, to avoid having network snoopers lift the token and do Man-in-the-Middle attacks.
 
B Ortet
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks man. Ive been using ranch for some time now, to look on some opinions about the the java certifications and to clarify some doubts. Only now i registered though...
Im doing a school project. And its requiried for me to log the client ip address that log into the system. But as you said, the NAT protocol, will take some action here.
I forgot about that, and i was thinking about using the and get the Client ipAddress and send it with the login credencials.
Thanks to you i see now its a bad ideia...

For the transport security ill check it later and get back to you.
 
Tim Holloway
Saloon Keeper
Posts: 22992
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The nominal source IP address is embedded in every network packet, of course, just not the definitive one. And, while I'm at it, I should probably point out that there are probably thousands, maybe millions of computers that have the IP address 192.168.1.131, since it's a non-unique address.

There are two common uses of the nominal source IP address, though. While they cannot uniquely identify who's connecting, they can be used to figure out what part of the world the request is probably coming from and which Internet Service Provider handled the originating traffic.

This nominal IP can then be used to fine-tune firewalls - for example, I had to completely block all emails originating from South Korea since all I ever got from that country were immense quantities of spam. It can also be captured in server logs, where it might be used for market analysis, for example. Of course, RMI is really only intended for internal LAN use, so RMI server implementations normally don't log at that level.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic