Forums Register Login

client machine name ip address

+Pie Number of slices to send: Send
Hi
i am trying to get the ip address of client machine and also its name. I found to get IP address but not the name of it when running on tomcat server. Following the code i tried



out put: this out put for the request made from the system in which the server is running (i.e., local host)

remote adress::0:0:0:0:0:0:0:1
inet address::0:0:0:0:0:0:0:1
comp name::KIHYDD0818



out put: this is out put for remote system request

remote adress::172.20.129.39
inet address::172.20.129.39
comp name::KIHYDD0818


see clearly i am able to get the ip address of remote system i.e., 172.20.129.39 but the name is same as local host. Here i think will always return the name of local host. but i need the name of remote system. please suggest me
+Pie Number of slices to send: Send
Two points:

1) Your code explicitly calls "getLocalHost()" - is it really surprising that you're getting the name of localhost? Note that that is a static method of InetAddress; what do the javadocs say it does?

2) Be aware that many (or most) machines will have not a name that can be looked up in this way. What you need to do is to perform a DNS lookup of that IP address's A record. The DNSJava library can do that pretty easily.
+Pie Number of slices to send: Send
Ok, i also tried servlet request methods




output
ip address::172.20.129.39
name::172.20.129.39

according to API request.getRemoteHost() should return qualified name of remote system, but i am still getting IP address for this statement. Can't we get the name of remote system.
+Pie Number of slices to send: Send
What do the javadocs of the getRemoteHost method have to say about that? They certainly don't say that it will always return a machine name.

But to me it doesn't look like 172.20.129.39 has a DNS A record, at least not a public one. Does it have a private A record in your network's DNS server? Most machines won't have that, though. And InetAddress knows nothing about remote machine names that aren't part of DNS, just in case that's what you were hoping for.
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 8791 times.
Similar Threads
How to know programmatically whether a machne is in Global/Private network ?
sloowwwww Reverse DNS lookup
Getting the Client machine name
Read Client IP Address behind Proxy
Can't get my Country name using InetAddressLocator
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:32:49.