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?
Example:

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 ;)

#!/bin/bash
# subutux@gmail.com
# http://blog.subutux.be
MAC=$1
#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.)

Enjoy!

Tags: , , , ,

Leave a Reply

Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).