我正在使用 SNMP 轮询交换机以获取数据。我正在尝试检索 MAC 地址表 ( sho mac address-table
) 以查看哪些设备连接到各个端口,但我似乎遇到了问题。在所有其他帖子、问题和指南中,普遍的共识是BRIDGE-MIB::dot1dTpFdbTable
在该 MIB 中使用或使用另一个。无论出于何种原因,我都无法在我们的设备上使用此 OID。它总是吐槽“此 OID 的此代理上没有可用的此类对象”。
请求父对象snmpbulkwalk BRIDGE-MIB::dot1dBridge
似乎提供设置和杂项。数据,但没有显示 MAC 条目。我们所有的设备(例如 C3750、C3850 和 C4506)都是如此。这是一些示例输出(C3560E,iOS 版本 c3560e-universalk9-mz.122-55.SE3):
BRIDGE-MIB::dot1dBaseBridgeAddress.0 = STRING: 30:f7:d:4b:c8:0
BRIDGE-MIB::dot1dBaseNumPorts.0 = INTEGER: 6 ports
BRIDGE-MIB::dot1dBaseType.0 = INTEGER: transparent-only(2)
BRIDGE-MIB::dot1dBasePort.25 = INTEGER: 25
BRIDGE-MIB::dot1dBasePort.26 = INTEGER: 26
BRIDGE-MIB::dot1dBasePort.27 = INTEGER: 27
BRIDGE-MIB::dot1dBasePort.28 = INTEGER: 28
BRIDGE-MIB::dot1dBasePort.29 = INTEGER: 29
BRIDGE-MIB::dot1dBasePort.30 = INTEGER: 30
BRIDGE-MIB::dot1dBasePortIfIndex.25 = INTEGER: 10125
BRIDGE-MIB::dot1dBasePortIfIndex.26 = INTEGER: 10126
BRIDGE-MIB::dot1dBasePortIfIndex.27 = INTEGER: 10127
BRIDGE-MIB::dot1dBasePortIfIndex.28 = INTEGER: 10128
BRIDGE-MIB::dot1dBasePortIfIndex.29 = INTEGER: 10201
BRIDGE-MIB::dot1dBasePortIfIndex.30 = INTEGER: 10202
BRIDGE-MIB::dot1dBasePortCircuit.25 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortCircuit.26 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortCircuit.27 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortCircuit.28 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortCircuit.29 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortCircuit.30 = OID: SNMPv2-SMI::zeroDotZero
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.25 = Counter32: 0
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.26 = Counter32: 0
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.27 = Counter32: 0
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.28 = Counter32: 0
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.29 = Counter32: 0
BRIDGE-MIB::dot1dBasePortDelayExceededDiscards.30 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.25 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.26 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.27 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.28 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.29 = Counter32: 0
BRIDGE-MIB::dot1dBasePortMtuExceededDiscards.30 = Counter32: 0
BRIDGE-MIB::dot1dTpLearnedEntryDiscards.0 = Counter32: 0
BRIDGE-MIB::dot1dTpAgingTime.0 = INTEGER: 300 seconds
BRIDGE-MIB::dot1dTpPort.25 = INTEGER: 25 BRIDGE-MIB::dot1dTpPort.26 =
INTEGER: 26 BRIDGE-MIB::dot1dTpPort.27 = INTEGER: 27
BRIDGE-MIB::dot1dTpPort.28 = INTEGER: 28 BRIDGE-MIB::dot1dTpPort.29 =
INTEGER: 29 BRIDGE-MIB::dot1dTpPort.30 = INTEGER: 30
BRIDGE-MIB::dot1dTpPortMaxInfo.25 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortMaxInfo.26 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortMaxInfo.27 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortMaxInfo.28 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortMaxInfo.29 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortMaxInfo.30 = INTEGER: 1510 bytes
BRIDGE-MIB::dot1dTpPortInFrames.25 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInFrames.26 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInFrames.27 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInFrames.28 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInFrames.29 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInFrames.30 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.25 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.26 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.27 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.28 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.29 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortOutFrames.30 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.25 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.26 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.27 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.28 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.29 = Counter32: 0 frames
BRIDGE-MIB::dot1dTpPortInDiscards.30 = Counter32: 0 frames
我知道交换机正在正确收集 MAC 地址,因为它通过 CLI 报告如下:
All 0100.0ccc.cccc STATIC CPU
All 0100.0ccc.cccd STATIC CPU
All 0180.c200.0000 STATIC CPU
All 0180.c200.0001 STATIC CPU
All 0180.c200.0002 STATIC CPU
All 0180.c200.0003 STATIC CPU
All 0180.c200.0004 STATIC CPU
All 0180.c200.0005 STATIC CPU
All 0180.c200.0006 STATIC CPU
All 0180.c200.0007 STATIC CPU
All 0180.c200.0008 STATIC CPU
All 0180.c200.0009 STATIC CPU
All 0180.c200.000a STATIC CPU
All 0180.c200.000b STATIC CPU
All 0180.c200.000c STATIC CPU
All 0180.c200.000d STATIC CPU
All 0180.c200.000e STATIC CPU
All 0180.c200.000f STATIC CPU
All 0180.c200.0010 STATIC CPU
All ffff.ffff.ffff STATIC CPU
100 001e.4a92.5c59 DYNAMIC Gi0/24
100 0024.c33c.719d DYNAMIC Gi0/24
100 0024.c3a8.9c00 DYNAMIC Gi0/24
100 b000.b4bf.9798 DYNAMIC Gi0/24
200 0024.c33c.719d DYNAMIC Gi0/24
200 0024.c3a8.9c00 DYNAMIC Gi0/24
500 0080.7752.bbb6 DYNAMIC Gi0/1
200 2c27.d720.3e4d DYNAMIC Gi0/24
200 3417.eb98.f48e DYNAMIC Gi0/24
200 b8a3.8607.a6ef DYNAMIC Gi0/24
...
为了使数据可用,我需要添加配置中的设置吗?此 OID 是否已被弃用且不再可用?
解决方案
在其他位置显示的 SNMP 实现之一中省略了一个小细节。我没有认出它,但这可能是因为我对 SNMP 不够熟悉,或者因为它是多么微妙。
轮询BRIDGE-MIB::dot1dTpFdbTable
OID 时,您必须将要查找的 VLAN 附加到社区字符串。我在解决方案中没有注意到这一点,因为通常所说的社区字符串是通用的。
例如:
snmpbulkwalk -v2c -cpublic hostname BRIDGE-MIB::dot1dTpFdbTable
将返回“此 OID 中当前不存在此类实例”
snmpbulkwalk -v2c -cpublic@vlan hostname BRIDGE-MIB::dot1dTpFdbTable
将返回此 VLAN 内的所有 MAC 地址。注意添加的@vlan。