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.