cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
12826
Views
5
Helpful
9
Replies

How to get 'mac address count' through SNMP (cisco 2950)

TopLekTopLek
Level 1
Level 1

HI,  Normally I'm getting total mac address space available by typing command: "show mac-address-table count" but I need to get this information through SNMP protocol. Could someone please send me an OID for this or show where to find MIBS for this cisco.  best regards Piotr Polok

3 Accepted Solutions

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

Find out the number of VLANs on the switch by:

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public 192.168.0.251 vtpVlanState 2>/dev/null

CISCO-VTP-MIB::vtpVlanState.1.1 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.20 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.30 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.40 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.70 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1002 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1003 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1004 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1005 = INTEGER: operational(1)

Foreach Vlan execute snmpwalk on the oid to find out the number of macs on the vlan.

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public 192.168.0.251 dot1dTpFdbAddress  2>/dev/null | perl -lne 'END { print $. }'

21

Twenty-one mac entries are on vlan 1 (default vlan).

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2>/dev/null | perl -lne 'END { print $. }'

1

One mac entry is on vlan 20.

ect....

HTH,

Dan

View solution in original post

Piotr Polok wrote:

HI,  Thank you for the answers. 

This command:

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

Following solution works but takes a long time:  snmpwalk -v 2c -c public 192.168.200.200 .1.3.6.1.2.1.17.4.3.1.1 |wc -l  

I do not have an access to this:  Using SNMP

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress) http://www.cisco.com/en/US/customer/tech/tk648/tk362/technologies_tech_note09186a0080094a9b.shtml 

The Cisco EEM script:   http://forums.cisco.com/eforum/servlet/EEM;jsessionid=5CD9466C02021001E06F256E55777159.SJ2A?page=eem&fn=script&scriptId=1741  looks to be great solution, but I have no idea how to use it. Could you please help me  

br Piotr Polok

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

OID for this is not going to be present since vlan20 is not on your switch.

try using it for vlan 1:

samson:~# snmpwalk -v 2c -c public

View solution in original post

The BRIDGE-MIB is supported on this platform.  I believe you have an issue on your snmp client with how the mib files are complled.

Try asking for this oid using the numberic number (not compiling the mib files).

[dafrey@HammerHead bin]$ snmptranslate -On BRIDGE-MIB::dot1dTpFdbAddress

.1.3.6.1.2.1.17.4.3.1.1

Execute:

snmpwalk -v 2c -c public 192.168.200.200 .1.3.6.1.2.1.17.4.3.1.1

Example:

User root does not know what path to compile the mib when asking for the textual oid:

[root@HammerHead bin]# snmpwalk -v 2c -c public 192.168.0.251 dot1dTpFdbAddress

dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

[root@HammerHead bin]#

User root asking for the oid in numberic form is successful:

[root@HammerHead bin]# snmpwalk -v 2c -c public 192.168.0.251 .1.3.6.1.2.1.17.4.3.1.1

SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.108.20.253.193 = Hex-STRING: 00 01 6C 14 FD C1

SNMPv2-SMI::mib-2.17.4.3.1.1.0.3.186.11.152.144 = Hex-STRING: 00 03 BA 0B 98 90

SNMPv2-SMI::mib-2.17.4.3.1.1.0.12.241.234.183.60 = Hex-STRING: 00 0C F1 EA B7 3C

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.141 = Hex-STRING: 00 0D ED 87 2D 8D

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.142 = Hex-STRING: 00 0D ED 87 2D 8E

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.143 = Hex-STRING: 00 0D ED 87 2D 8F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.141 = Hex-STRING: 00 0D ED C2 AA 8D

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.142 = Hex-STRING: 00 0D ED C2 AA 8E

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.143 = Hex-STRING: 00 0D ED C2 AA 8F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.146 = Hex-STRING: 00 0D ED C2 AA 92

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.15 = Hex-STRING: 00 1B D5 1A 67 0F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.16 = Hex-STRING: 00 1B D5 1A 67 10

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.17 = Hex-STRING: 00 1B D5 1A 67 11

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.64 = Hex-STRING: 00 1B D5 1A 67 40

SNMPv2-SMI::mib-2.17.4.3.1.1.0.35.51.130.11.48 = Hex-STRING: 00 23 33 82 0B 30

SNMPv2-SMI::mib-2.17.4.3.1.1.0.35.51.130.11.57 = Hex-STRING: 00 23 33 82 0B 39

SNMPv2-SMI::mib-2.17.4.3.1.1.0.36.20.172.15.136 = Hex-STRING: 00 24 14 AC 0F 88

SNMPv2-SMI::mib-2.17.4.3.1.1.0.36.151.251.1.54 = Hex-STRING: 00 24 97 FB 01 36

SNMPv2-SMI::mib-2.17.4.3.1.1.110.0.0.0.132.50 = Hex-STRING: 6E 00 00 00 84 32

SNMPv2-SMI::mib-2.17.4.3.1.1.110.0.0.0.134.0 = Hex-STRING: 6E 00 00 00 86 00

View solution in original post

9 Replies 9

Dan Frey
Cisco Employee
Cisco Employee

Find out the number of VLANs on the switch by:

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public 192.168.0.251 vtpVlanState 2>/dev/null

CISCO-VTP-MIB::vtpVlanState.1.1 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.20 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.30 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.40 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.70 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1002 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1003 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1004 = INTEGER: operational(1)

CISCO-VTP-MIB::vtpVlanState.1.1005 = INTEGER: operational(1)

Foreach Vlan execute snmpwalk on the oid to find out the number of macs on the vlan.

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public 192.168.0.251 dot1dTpFdbAddress  2>/dev/null | perl -lne 'END { print $. }'

21

Twenty-one mac entries are on vlan 1 (default vlan).

[dafrey@HammerHead ~]$ snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2>/dev/null | perl -lne 'END { print $. }'

1

One mac entry is on vlan 20.

ect....

HTH,

Dan

Richard Michael
Cisco Employee
Cisco Employee

Hello Piotr,

There is no specific OID that aggregates the count across the entire switch as to the

number of MAC addresses learned by the device. Only the CLI command offers this specific

information. Not every CLI command permutation offers as corresponding SNMP equivalent.

Specifically, you can use the following MIB/OID(s) to get the information in a multistep

process as the following context is VLAN aware.

.1.3.6.1.2.1.17.4

+--dot1dTpFdbTable(3) detail

   |

   +--dot1dTpFdbEntry(1) detail

   |  |

   |  +-- -R-- String    dot1dTpFdbAddress(1)

   |  |        Textual Convention: MacAddress

   |  |        Size: 6

   |  +-- -R-- Integer   dot1dTpFdbPort(2)

   |  +-- -R-- EnumVal   dot1dTpFdbStatus(3)

   |  |        Values: other(1), invalid(2), learned(3), self(4), mgmt(5)

Ideally, one would do and SNMPWALK of dot1dTpFdbStatus or dot1dTpFdbAddress for the

specific VLAN of choice. The default VLAN is 1. Then piping this information to the WC

(word count) command:

    Linux / Unix wc command

    About wc

    Short for word count, wc displays a count of lines, words, and characters in a file.

    Syntax:

    wc [-c | -m | -C ] [-l] [-w] [ file ... ]

    -c    Count bytes.

    -m    Count characters.

    -C    Same as -m.

    -l    Count lines.

-w    Count words delimited by white space characters or new line characters. Delimiting

characters are Extended Unix Code (EUC) characters from any code set defined by iswspace()

    file    Name of file to word count.

I found a Windows Equivalent through a Google search.

Please take into account that Cisco uses community string indexing to separate information

on a per vlan basis. I have include the links about this below.

Reference

-------------

How to Get Dynamic CAM Entries (CAM Table) for Catalyst Switches Using SNMP

http://www.cisco.com/en/US/partner/tech/tk648/tk362/technologies_tech_note09186a0080094a9b.shtml

SNMP Community String Indexing

http://www.cisco.com/en/US/partner/tech/tk648/tk362/technologies_tech_note09186a00801576ff.shtml

Using SNMP

http://www.cisco.com/en/US/customer/tech/tk648/tk362/technologies_tech_note09186a0080094a9b.shtml

Other than what has been provided, only the CLI would give you what you want. Note that

the BRIDGE-MIB is not a Cisco specific mib.

CLI command to look at would give the number of Dynamic (learned) addresses: Show

mac-address-table dynamic: To display dynamic MAC address table entries only, use the show

mac-address-table dynamic command in privileged EXEC mode.

however, As an alternative, you can go for the Cisco EEM script,

http://forums.cisco.com/eforum/servlet/EEM;jsessionid=5CD9466C02021001E06F256E55777159.SJ2A?page=eem&fn=script&scriptId=1741

The above link would satisfy your needs

Thanks,

Ricky Micky

Please rate if this answer was useful

HI,  Thank you for the answers. 

This command:

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

Following solution works but takes a long time:  snmpwalk -v 2c -c public 192.168.200.200 .1.3.6.1.2.1.17.4.3.1.1 |wc -l  

I do not have an access to this:  Using SNMP

http://www.cisco.com/en/US/customer/tech/tk648/tk362/technologies_tech_note09186a0080094a9b.shtml 

The Cisco EEM script:   http://forums.cisco.com/eforum/servlet/EEM;jsessionid=5CD9466C02021001E06F256E55777159.SJ2A?page=eem&fn=script&scriptId=1741  looks to be great solution, but I have no idea how to use it. Could you please help me  

br Piotr Polok

What Vlans are currently configured on the switch?

Switch#show vlan

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8, Fa0/9, Fa0/10, Fa0/11, Fa0/12, Fa0/13, Fa0/14, Fa0/15, Fa0/16, Fa0/17, Fa0/18, Fa0/19, Fa0/21, Fa0/22, Fa0/23, Fa0/24, Gi0/2

1002 fddi-default                     act/unsup

1003 token-ring-default               act/unsup

1004 fddinet-default                  act/unsup

1005 trnet-default                    act/unsup

Piotr Polok wrote:

HI,  Thank you for the answers. 

This command:

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

Following solution works but takes a long time:  snmpwalk -v 2c -c public 192.168.200.200 .1.3.6.1.2.1.17.4.3.1.1 |wc -l  

I do not have an access to this:  Using SNMP

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress) http://www.cisco.com/en/US/customer/tech/tk648/tk362/technologies_tech_note09186a0080094a9b.shtml 

The Cisco EEM script:   http://forums.cisco.com/eforum/servlet/EEM;jsessionid=5CD9466C02021001E06F256E55777159.SJ2A?page=eem&fn=script&scriptId=1741  looks to be great solution, but I have no idea how to use it. Could you please help me  

br Piotr Polok

samson:~# snmpwalk -v 2c -c public@20 192.168.0.251 dot1dTpFdbAddress  2 

giving me an error: dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

OID for this is not going to be present since vlan20 is not on your switch.

try using it for vlan 1:

samson:~# snmpwalk -v 2c -c public

HI, it's the same...

samson:~# snmpwalk -v 2c -c public 192.168.200.200  dot1dTpFdbAddress

dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

The BRIDGE-MIB is supported on this platform.  I believe you have an issue on your snmp client with how the mib files are complled.

Try asking for this oid using the numberic number (not compiling the mib files).

[dafrey@HammerHead bin]$ snmptranslate -On BRIDGE-MIB::dot1dTpFdbAddress

.1.3.6.1.2.1.17.4.3.1.1

Execute:

snmpwalk -v 2c -c public 192.168.200.200 .1.3.6.1.2.1.17.4.3.1.1

Example:

User root does not know what path to compile the mib when asking for the textual oid:

[root@HammerHead bin]# snmpwalk -v 2c -c public 192.168.0.251 dot1dTpFdbAddress

dot1dTpFdbAddress: Unknown Object Identifier (Sub-id not found: (top) -> dot1dTpFdbAddress)

[root@HammerHead bin]#

User root asking for the oid in numberic form is successful:

[root@HammerHead bin]# snmpwalk -v 2c -c public 192.168.0.251 .1.3.6.1.2.1.17.4.3.1.1

SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.108.20.253.193 = Hex-STRING: 00 01 6C 14 FD C1

SNMPv2-SMI::mib-2.17.4.3.1.1.0.3.186.11.152.144 = Hex-STRING: 00 03 BA 0B 98 90

SNMPv2-SMI::mib-2.17.4.3.1.1.0.12.241.234.183.60 = Hex-STRING: 00 0C F1 EA B7 3C

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.141 = Hex-STRING: 00 0D ED 87 2D 8D

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.142 = Hex-STRING: 00 0D ED 87 2D 8E

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.135.45.143 = Hex-STRING: 00 0D ED 87 2D 8F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.141 = Hex-STRING: 00 0D ED C2 AA 8D

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.142 = Hex-STRING: 00 0D ED C2 AA 8E

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.143 = Hex-STRING: 00 0D ED C2 AA 8F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.13.237.194.170.146 = Hex-STRING: 00 0D ED C2 AA 92

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.15 = Hex-STRING: 00 1B D5 1A 67 0F

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.16 = Hex-STRING: 00 1B D5 1A 67 10

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.17 = Hex-STRING: 00 1B D5 1A 67 11

SNMPv2-SMI::mib-2.17.4.3.1.1.0.27.213.26.103.64 = Hex-STRING: 00 1B D5 1A 67 40

SNMPv2-SMI::mib-2.17.4.3.1.1.0.35.51.130.11.48 = Hex-STRING: 00 23 33 82 0B 30

SNMPv2-SMI::mib-2.17.4.3.1.1.0.35.51.130.11.57 = Hex-STRING: 00 23 33 82 0B 39

SNMPv2-SMI::mib-2.17.4.3.1.1.0.36.20.172.15.136 = Hex-STRING: 00 24 14 AC 0F 88

SNMPv2-SMI::mib-2.17.4.3.1.1.0.36.151.251.1.54 = Hex-STRING: 00 24 97 FB 01 36

SNMPv2-SMI::mib-2.17.4.3.1.1.110.0.0.0.132.50 = Hex-STRING: 6E 00 00 00 84 32

SNMPv2-SMI::mib-2.17.4.3.1.1.110.0.0.0.134.0 = Hex-STRING: 6E 00 00 00 86 00

HI,

Thank, this is very helpful.

best regards

Piotr Polak

Review Cisco Networking products for a $25 gift card