Last active
March 16, 2026 22:01
-
-
Save scrivocodice/9b9047ee35a3c0e5880937a14807f690 to your computer and use it in GitHub Desktop.
Scan neighbors network devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """List all hosts with their IP address on my subnet.""" | |
| import os | |
| out = os.popen('ip neighbour show nud reachable').read().splitlines() | |
| for i, line in enumerate(out, start=1): | |
| ip = line.split(' ')[0] | |
| h = os.popen(f'host {ip}').read() | |
| hostname = h.split(' ')[-1] | |
| print(f"{i:>3}: {hostname.strip()} ({ip})") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment