Skip to content

Instantly share code, notes, and snippets.

@niun
Last active September 16, 2022 12:06
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niun/7c1a1da47d0f433e2ad5 to your computer and use it in GitHub Desktop.
Save niun/7c1a1da47d0f433e2ad5 to your computer and use it in GitHub Desktop.
Find Raspberry Pi in network (looking for MAC address vendor prefix of Raspberry Pi Foundation using nmap, awk for ipv4 / ping6, ip, grep for ipv6 neighbour discovery)
sudo nmap -sP 192.168.0.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
IFACE=eth0
# trigger IPv6 neighbour discovery with link-local scope multicast:
ping6 -c2 -I $IFACE ff02::1 > /dev/null
# print the results, filtered by MAC address vendor prefix of Raspberry Pi Foundation:
ip -6 neigh | grep b8:27:eb
@LuisDiazUgena
Copy link

LuisDiazUgena commented Mar 13, 2018

Thanks. It was very useful. I've done some small changes to recursively search until the user breaks the loop:

echo "************************"
echo "Prees [Ctrl + C] to exit"
echo "************************"
IFACE=wlan0
#IFACE=eth0
# trigger IPv6 neighbour discovery with link-local scope multicast:
ping6 -c2 -I $IFACE ff02::1 > /dev/null
# print the results, filtered by MAC address vendor prefix of Raspberry Pi Foundation:
while :
do
        ip -6 neigh | grep b8:27:eb
        sleep 30
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment