Skip to content

Instantly share code, notes, and snippets.

@amitness
Created March 13, 2019 12:00
Show Gist options
  • Save amitness/1ddd563099bb8afe683d44f9c750e98c to your computer and use it in GitHub Desktop.
Save amitness/1ddd563099bb8afe683d44f9c750e98c to your computer and use it in GitHub Desktop.
Get the IP address of all device on the local network
import os
import re
output = os.popen('arp -a').read().splitlines()
ips = [re.search(r'\d+\.\d+\d+.\d+.\d+', b).group(0) for b in output]
for ip in ips:
print(os.popen('nmblookup -A {}'.format(ip)).read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment