[Tutor] getting network device names

nathan Smith nathan-tech at hotmail.com
Fri May 14 09:00:28 EDT 2021


Hi list,


I figured I'd ask here in case I'm missing something.

I'm trying to write a small program that would be able to get a list of 
devices connected to the same one as my laptop, EG the devices on the 
router and display that in a list of IP and device name.

I'm running python 3.8 on windows and so far can get a list of IP 
addresses through the arp -a command and putting it through os.popen to 
process the results.

As far as I can see though the only way to get the device names is 
through nmap which does not come by default on windows and doesn't look 
like it's made to be distributed as part of a package.

I know though that socket.gethostname() returns my local computer's 
name, so wonder if I am missing something?

Maybe I can do some form of call to the dns of the router itself?

socket.gethostbyaddr(an-ip-address) times out for local IP addresses.


Thanks for any help

Nathan



More information about the Tutor mailing list