How do you search for an IP address given a MAC address, on a Cisco switch?

I have to develop a scrip that will find an IP address given a MAC address on a Cisco switch. The script must be written for a Unix server and run in intervals of about 30 minutes.

I should say that I am a complete novice in this matter, but I am a quick learner.

The issue is, I live on a small island, and my MacBook Pro was stolen, but I have my MAC address. The local ISP will help me locate the laptop if I write a script to associate an IP with my MAC. It should run about every 30 seconds and notify both the network administrator and me.  I am a programmer but this is unfamiliar territory for me. I would greatly appreciate some guidance.  
theunconventionalplatinumAsked:
Who is Participating?
 
grsteedConnect With a Mentor Commented:
If the switch is only layer 2, than you may not be able to see the IP address unless it happens to be on the same network that switch management IP address is on. That is, the same network that you telnet/ssh to  when accessing the switch console. If you issue the command "show arp" or "show ip arp" you will see the MAC's and IP's for that network.  If it's a long list use the form "show ip arp | in <MAC>" where in=include and <MAC> is your MAC address.   If you don't see your MAC listed that way, you can try the command "show mac-address-table dynamic | in <MAC>"  That will show you if you MAC shows up on a port on that switch, of a trunk/port channel that connects to another switch. If that's what you see, you need to go to the next switch and issue the same command.  This will eventually get you to the port that your laptop is showing up on.

The best place to get MAC -> IP information is from the router arp cache, or the arp cache of a layer 3 switch with the command "show ip arp | in <MAC>"

To run this from a Unix server, you may want to use TCL/Expect which uses  SEND and EXPECT commands to send a string and wait for a string back.  With it you can script a telnet/ssh to a device, wait for login prompt, send login, wait for password prompt, send password, wait for prompt, send command, wait for output etc...  a sample can be found here.

http://www.corecoding.com/cisco-expect-script_c32.html

Hope this helps.

Gary

0
 
atlas_shudderedConnect With a Mentor Sr. Network EngineerCommented:
One other item of note, if the switch in question is capable of running the Cisco Network Assistant, you can perform a layer 2 trace.  The downside to this is that it will not run automatically.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.