Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@treyhunner
Created December 30, 2012 19:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treyhunner/4414570 to your computer and use it in GitHub Desktop.
Save treyhunner/4414570 to your computer and use it in GitHub Desktop.
Script for finding Raspberry Pi computers on the network. The scripts searches for MAC addresses starting with `b8:27:eb:` (the Ethernet port on the Pi) and `80:1f:02` (Edimax wifi USB dongle).
#!/bin/sh
if which nmap > /dev/null ; then
echo "Running nmap as root\n"
IP_RANGE=$(ip addr | grep "inet " | awk '{ print $2}' | grep -v 127.0.0)
sudo nmap -sP $IP_RANGE | grep -B2 -i 'b8:27:eb\|80:1f:02'
else
if which arp-scan > /dev/null ; then
echo "Running arp-scan as root\n"
sudo arp-scan --interface=eth0 --localnet | grep 'b8:27:eb\|80:1f:02'
else
echo "Error: Must instal nmap or arp-scan." 1>&2
echo "To install nmap on Ubuntu:" 1>&2
echo " sudo apt-get install nmap" 1>&2
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment