-
-
Save danmackinlay/2c970aec992a59eab7dda739b974ea9a to your computer and use it in GitHub Desktop.
Find Raspberry Pi devices on your local networks.
This file contains 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
#!/bin/sh | |
# get broadcast addresses for each network | |
net=`ifconfig | grep -o -E "Bcast:(.*?) " | cut -f2 -d":"` | |
# loop over networks running the scan | |
for n in $net; | |
do | |
# first find SSH machines silently to prime the arp table | |
nmap -T4 -n -p 22 --open --min-parallelism 100 "$n/24" | grep -e "scan report for" -e "ssh" > /dev/null | |
done | |
# then run arp to show machines pi MACs | |
# https://udger.com/resources/mac-address-vendor-detail?name=raspberry_pi_foundation | |
arp -na | grep -E "(b8:27:eb|dc:a6:32)" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment