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.
get_mac_port.pl ([-m <mac-address>]| [-i <ip address> -r <router>]) -f <file> -c <community> [-hV]
Where:
<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.
Download
Hi there,
ReplyDeleteThis 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 1.3.6.1.2.1.3.1.1.2 No results Net::SNMP=HASH(0x8760fac)->error
The switches I have are Cisco 2950 and 3750. The command I use is
./get_mac_port.pl -i 192.168.244.201 -r 192.168.244.1 -f tmp/switch.ip -c public
And I runs this command on a Fedora Core 5 system.
Any comments, please?
Thanks,
Liang