-1

Currently I'm trying to write a Python script to scan through my local network, and list all of the active IP addresses, and their corresponding MAC address and device name. Also all of the devices connected to my network are wireless devices. For example, if I had my phone, laptop and chromecast connected to the network, the script would show the following:

IP address: 192.168.1.3, MAC: xx:xx:xx:xx:xx:xx, Name: Galaxy-S20

IP address: 192.168.1.4, MAC: xx:xx:xx:xx:xx:xx, Name: Macbook-Pro

IP address: 192.168.1.5, MAC: xx:xx:xx:xx:xx:xx, Name: Google-Chromecast

After doing some research, I know that its fairly simple to grab the IP address-MAC address pairing through an arp scan. The nmap library can also be used to get a more information about each device, like the ports they use, the OS they are running, etc.

However, is there a way to determine the name of each device (as they appear when e.g. logging into your router and looking at the list of clients)?

Note: Running nmap -sn 192.168.1.* is supposed to give you the hostname of the specified IP, however, in my case, it didn't seem to work for a majority of devices as this command will not return the hostname if the device does not respond to ICMP.

  • What makes you believe it's possible? There is no protocol for discovering hostnames; it depends on how your devices is set up. – vidarlo Apr 22 '23 at 15:11

1 Answers1

0

is there a way to determine the name of each device?

No, not reliably. A device may not respond to anything, or only respond with minimal network information that would not include any name(s), of which there may be multiple.

Of course your business environment would not allow unknown devices, so there is most likely a repository of the information for each device on your network, such as a DHCP Server, 802.1x authentication database, various endpoint agent databases, etc. Combining these multiple sources of information is usually the most effective way to identify known and unknown devices.

Greg Askew
  • 35,880
  • 5
  • 54
  • 82