Score:-1

How to find device names on local network?

aw flag

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.

vidarlo avatar
ar flag
What makes you believe it's possible? There is no protocol for discovering hostnames; it depends on how your devices is set up.
Score:0
cn flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.