markwallsgrove

Find all IP addresses on subnet with mac address

Apr 2nd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. while read line
  3. do
  4.     vendorMac=`echo $line | awk ' { print gensub(/^(.+:.+:.+):/, "\\\1", "g", $2); } '`
  5.     vendor=`wget -qO- http://www.macvendorlookup.com/api/v2/$vendorMac 2>/dev/null | base64 | awk ' { printf "%s", $0 } '`
  6.     echo "$line $vendor"
  7. done
  8.  
  9. #!/usr/bin/env bash
  10. prefix=`ifconfig eth0 | awk '/inet addr/ { print gensub(/Bcast:(.+)\.[0-9]+$/, "\\\1", "g", $3) } '`
  11. for i in `seq 254`; do
  12.     ping -c1 -w1 $prefix.$i &> /dev/null && arp -n | awk ' /'$prefix'.'$i' / { print $1 " " $3 } ' &
  13. done
  14. wait
Advertisement
Add Comment
Please, Sign In to add comment