0

I'm trying to get the hostname associated with an IP address on my LAN. I've looked at the solutuon for Need to perform a reverse DNS lookup of a particular IP address in java, which is basically:

InetAddress ia = InetAddress.getByName("192.168.1.3");
System.out.println(ia.getHostName());

The output is:

192.168.1.3

so all it tells me is the address that I provided!

The thing is, if I download an application like Fing onto my phone and run a scan of my network then I can see the hostnames of the devices. Fing must have got that information from somewhere. I'd like to do something similar.

What has Fing been able to do to get this information and how can I do the same?

Stormcloud
  • 2,065
  • 2
  • 21
  • 41
  • Is the device registered in DNS? – Ron Maupin Aug 25 '20 at 20:05
  • If running on a client, this does the trick: InetAddress.getLocalHost().getHostName() – Jon H Aug 25 '20 at 20:08
  • @Ron Maupin, All the devices on my LAN should use DHCP, so I would expect the DNS server to know something about them – Stormcloud Aug 26 '20 at 09:05
  • @Jon H, Sorry but your trick only works for localhost – Stormcloud Aug 26 '20 at 09:06
  • DHCP and DNS are two completely different things. Unless you have a DHCP server that is configured to name a device and send that name to the DNS server, then no, the DNS server will not have a name for the device. There is nothing in standard DHCP that knows anything about names. – Ron Maupin Aug 26 '20 at 13:19

0 Answers0