cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Find access port for a given MAC address using simple batch and SNMP

3666
Views
0
Helpful
3
Comments

I was playing around with SNMP one day and decided to find out if I could create a MS-DOS batch job using only a single batch file and a free SNMP command line tool from the Internets.  Here's what I came up with.  To get this to work you need the following:

1.  Create a directory (ie, C:\BATCH\FINDMAC)

2.  Place FINDMAC.CMD into directory from step #1 (save attachment as FINDMAC.CMD)

3.  Create a file in directory from step #1 called sitelist.txt.  This file should be a simple text file, comma-delimited, with two items per record.  Neither item can have spaces.  Item 1 should be a friendly name to identify a site or a distribution layer device.  It's just something that you can easily remember.  Item 2 is a FQDN or IP address of a seed device (typically, this would be a distribution switch on which one or more layer 3 neworks terminate).

4.  Download SNMP command line tools from net-snmp.org and install into the path (or modify the script to point to the correct location for the SNMPGET and SNMPWALK programs)

5.  Open a DOS window, navigate to the directory from step #2 and type "findmac.cmd <sitename> <macaddress>" where <sitename> matches a site from sitelist.txt and <macaddress> is a mac address in the format xx.xx.xx.xx.xx.xx

This process works great for me on a Windows 7 workstation.  I can quickly locate the access port for any MAC address at our HQ or any of our branch locations.  Our environment has 7Ks, 5Ks, 6500s, 3750s, and 3550s.

Comments
Rising star

Very nice.

It shows that with a little scripting you can do very powerfull things on the devices using SNMP

Hope to see a SNMP V3 version soon  :-)

Beginner

It'd be nice to get v3 working but so far I've been unsuccessful at that.  There's documentation on the website from which I get the SNMP command line tools but I haven't been able to get it to work on the Windows platform.  If anybody figures that part out let me know.

freaking brilliant

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards