Skip to content

Instantly share code, notes, and snippets.

@cod1ingcoding
Created September 5, 2019 00:38
Show Gist options
  • Save cod1ingcoding/0a178cb79cb486d45f8b257b8a850d85 to your computer and use it in GitHub Desktop.
Save cod1ingcoding/0a178cb79cb486d45f8b257b8a850d85 to your computer and use it in GitHub Desktop.
get all ip mac pairs in current lan
#!/bin/bash
ip_prefix=192.168.1
for((i = 1; i < 255; i++))
do
ip=${ip_prefix}.${i}
ping $ip -c 2
arp -a | grep "(${ip})" | grep -E [0-9a-f]{2}:[0-9a-f]{2} >> ~/ip-mac-pairs.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment