Today I was browsing through the Cisco NetPro Forums and came across someone that needed to track down which switch port a
<acronym title="Media Access Control">MAC
</acronym> address had been dynamically learned on.
I'd seen this sort of thing before in the Bridge MIB, so I assumed it was possible. (The necessary OID is dot1dTpFdbAddress - 18.104.22.168.22.214.171.124.3.1.1).
I started testing on my own systems by selecting a MAC address at random from one of my switches. No matter what I tried, I couldn't find that MAC address in the Bridge MIB. I even found an old Cisco document discussing exactly how to find this information. Still, nothing.
And that's when I noticed this little gem from that old document: "In order to access MIBs that have a separate instance for each VLAN, you must first understand how to use community string indexing."
Now change that look of surprise to the proverbial light bulb going off.
I had no idea that some of these MIBs had separate instances per VLAN. I also had no idea that in order to get that data I would need to add a VLAN-based index to my community string. Lo and behold, the randomly selected MAC address was in a VLAN other than VLAN 1!
So, I merely added '@22' to the end of my community string (the device in question was in VLAN 22) and quickly found the MAC address I was looking for.