Linux: Ping a mac address

Ever got into the situation where you’ve only got a mac address from a device and wanted to know what his ip is, or if it’s reachable?

I’ve placed an access point in a cisco catalyst switch. I want to know which ip it has. So i pull up the mac address-table on the cisco switch:

show mac-address table

and search the mac. Or I could:

show mac-address table interface Gi 0/24

to show the mac’s on all this ports (probably one if no client is connected to the AP)

so, now i’ve got my mac address.. now what? you can manually look up the ip via “arp -n | grep “[mac:address]” or you could use this script 😉

#echo $MAC
IP=`arp -n | grep "$MAC" | awk '{print $1}'`;
ping $IP

Simple as hell, quite handy as hell! (Not that hell is so handy.. but thats not the point.)



subutux wrote 34 posts

Post navigation

Leave a Reply