Val:~$ whoami

I am Val Glinskiy, network engineer specializing in data center networks. TIME magazine selected me as Person of the Year in 2006.

Search This Blog

Wednesday, October 25, 2006

Find a device on Cisco switch

I have a few dozens of Cisco switches running CatOS and IOS and from time to time I need to find the port on the switch where particular network device is connected to. Sometimes I know the MAC address and sometimes I know IP address only. Logging into every switch and running "show cam" or "show mac-address-table" is time consuming, but all my switches have SNMP on. I wrote a script which polls list of switches to find the device either by MAC or IP address. ([-m <mac-address>]| [-i <ip address> -r <router>]) -f <file> -c <community> [-hV]
<file> - list of switches (IP or names) in a text file, one per line.
<mac-address> - MAC address of the host. It should be in form of aa:23:cc:dd:ee:ff or aabb.ccdd.eeff
Both lower and upper case letters accepted.
<ip address> - IP address of the host.
<router> - IP address or name of the default gateway for the host's network. This is the best source to get host's MAC address from.
<community> - SNMP community string.

Known problem: If switches are interconnected via trunks, the script will report the device as connected to a trunk port.

1 comment:

  1. Hi there,

    This is great. And it is exactly the tool I am looking for. However after I downloaded and tried to my switches, it gives me following errors:

    ERROR:arpoid No results Net::SNMP=HASH(0x8760fac)->error

    The switches I have are Cisco 2950 and 3750. The command I use is
    ./ -i -r -f tmp/switch.ip -c public

    And I runs this command on a Fedora Core 5 system.

    Any comments, please?