Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

How to get Vlans of a switch using SNMP ??

Hello Everyone,

I have a problem with Cisco switch(catalyst). I want to get all the MAC address being served from the ports of the switch. I found Bridge-MIB which solved my purpose. But now I came to know that there are vlans ( gosh why the world cant be simple:-(( )

OK so here i am stuck up again, I have to use community indexing for all the vlans in order to know the MAC addresses being served from the ports. So can i know the vlans of a device ? I am using SNMP to communicate with the Switch. i know I can get the vlan information from CLI using "Show vlan" command and it just shows me all that I want. But how do i do it by reading MIB ? Which MIB should i look into to get all the vlan ids ?

I thought CISCO-VTP-MIB would help but when i do a snmpwalk on vtpVlanIndex ( full path ---> iso(1).org(3).dod(6).internet(1).private(4).enterprises(1).cisco(9).ciscoMgmt(9).ciscoVtpMIB(46).vtpMIBObjects(1).vlanInfo(3).vtpVlanTable(1).vtpVlanEntry(1).vtpVlanIndex(1) it doesnt return me any values ????

Meanwhile I found one more interesting MIB "CISCO-VLAN-MEMBERSHIP-MIB" and whola things seems to be getting better. I can get which ports belong to which vlan ( it could have been better if i could know the vlan ids since now i have to query for each port and then get the list of vlan ids and then remove the duplicate once and then change my community string to query Bridge-MIB for the MAC Address) ??

I just want to know if someone came accross such a problem ( I am sure someone must have ) and if yes then how did it got solved ?? and if no then am I moving on the right track for getting the vlan ids and then MAC addresss.

Have Fun and thanks a lot for any responses.

waiting eargely to hear from anyone ..



Re: How to get Vlans of a switch using SNMP ??

Hi Sunil,

I haven't faced such a problem, but I guess it would be a good idea to check if the CISCO-VTP-MIB is supported on the platform that you are running. There is a tool called the MIB Locator that is available to check if the MIB is supported on the device and the image used. Since you haven't mentioned the details of the platform and the image used by you I haven't been able to verify it myself. However here's the link and you could check it yourself.

This is the link to the page that contains other useful tools.

Hope this helps.

CreatePlease to create content