Last active
November 12, 2015 12:35
-
-
Save jandahl/3cd844ecc9c017e69361 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Made for bash, assumes you have a working rancid/clogin set up | |
# | |
# Point the below to your local copy of the list | |
OUIList=~/oui.txt | |
if [ ! -c $OUIList ] | |
then ## Check if $OUIList exists, if not, download and save it | |
# touch $OUIList | |
echo "Fetching the OUI list. This might take a little while. Like, 2 minutes." | |
curl http://standards-oui.ieee.org/oui.txt > "$OUIList" | |
ls -larthG $OUIList "$OUIList" | |
fi | |
function routerARP() { | |
# invoke with IP as argument | |
if [ -z "$1" ] | |
then ## Check for args, and if none, show "about" ditty | |
echo -e "\nMAC address looker upper.\nInvoke it with the router IP" | |
exit | |
else | |
for macEntry in $(clogin -c "show ip arp" $1 | grep ARPA | awk '{print $4}' | cut -c 1-4,6-7 | sort -u ) | |
do | |
grep -i "$macEntry" "$OUIList" | |
done | sort --key=3 | sed 's/.base 16.\t//g' | |
fi | |
} | |
function switchMAC() { | |
# invoke with IP as argument | |
if [ -z "$1" ]; then ## Check for args, and if none, show "about" ditty | |
echo -e "\nMAC address looker upper.\nInvoke it with the switch IP" | |
exit | |
else | |
for macEntry in $(clogin -c "show mac addr | e CPU" $1 | grep -e "\/" | cut -c 9-12,14-15 | sort -u ) | |
do | |
grep -i "$macEntry" "$OUIList" | |
done | sort --key=3 | sed 's/.base 16.\t//g' | |
fi | |
} | |
function macList() { | |
if [ -z "$1" ]; then ## Check for args, and if none, show "about" ditty | |
echo -e "\nMAC address looker upper.\nInvoke it with the text file name. Assumes MAC address in first column." | |
exit | |
else | |
for macEntry in $(cat $1 | cut -c 1-4,6-7 | sort -u ) | |
do | |
grep -i "$macEntry" "$OUIList" | |
done | sort --key=3 | sed 's/.base 16.//g' | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment