基本上我想要做的是找出插入交换机接口(例如 FastEthernet0/1)的设备的 mac 地址
通过阅读交换机文档,我发现我可以在其上配置 snmp trap,使其通过使用命令通知交换机检测到的任何新 mac 地址
snmp-server 启用 traps mac-notification
但出于某种原因,我的交换机不支持此功能。我看到的唯一选项是
CORE_SWITCH(config)#snmp-server enable traps ?
c2900 Enable SNMP c2900 traps
cluster Enable Cluster traps
config Enable SNMP config traps
entity Enable SNMP entity traps
hsrp Enable SNMP HSRP traps
snmp Enable SNMP traps
vlan-membership Enable VLAN Membership traps
vtp Enable SNMP VTP traps
<cr>
所以另一种方法是在我的网关上运行一个 cronjon,定期使用 snmp 轮询交换机以获取新的 mac 地址
我到处都找过了,但似乎找不到能给我提供此信息的 OID。
我将非常感激任何能提供的帮助!
这是我的交换机上“show version”的输出
Cisco Internetwork Operating System Software
IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5.4)WC(1), MAINTENANCE INTERIM SOFTWARE
Copyright (c) 1986-2001 by cisco Systems, Inc.
Compiled Tue 10-Jul-01 11:52 by devgoyal
Image text-base: 0x00003000, data-base: 0x00333CD8
ROM: Bootstrap program is C2900XL boot loader
CORE_SWITCH uptime is 1 hour, 24 minutes
System returned to ROM by power-on
System image file is "flash:c2900XL-c3h2s-mz.120-5.4.WC.1.bin"
cisco WS-C2912-XL (PowerPC403GA) processor (revision 0x11) with 8192K/1024K bytes of memory.
Processor board ID FAB0409X1WS, with hardware revision 0x01
Last reset from power-on
Processor is running Enterprise Edition Software
Cluster command switch capable
Cluster member switch capable
12 FastEthernet/IEEE 802.3 interface(s)
32K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: 00:01:42:D0:67:00
Motherboard assembly number: 73-3397-08
Power supply part number: 34-0834-01
Motherboard serial number: FAB040843G4
Power supply serial number: DAB05030HR8
Model revision number: A0
Motherboard revision number: C0
Model number: WS-C2912-XL-EN
System serial number: FAB0409X1WS
Configuration register is 0xF
谢谢,-ankit
答案1
我不确定它是否受 2900/IOS 12.0 支持,但您可以尝试使用 dot1dTpFdbPort (.1.3.6.1.2.1.17.4.3.1.2) 您需要使用一个特殊的社区字符串,其中包括您想要获取 mac 地址表的 vlan:community@vlan_number 因此,如果您的交换机是 1.2.3.4,使用社区 snmpro 并有 vlan 30,请尝试以下操作:
snmpwalk -v2c -c snmpro@30 1.2.3.4 1.3.6.1.2.1.17.4.3.1.2
答案2
Radius,谢谢你给我指明了正确的方向。根据您的建议,我在 Google 上搜索了一下,我想我现在明白了。
对于可能需要它的任何人来说,这是程序......
1. get the mac address detected on a vlan (1 in this example)
snmpwalk -c public@1 -v2c 10.1.1.10 1.3.6.1.2.1.17.4.3.1.1
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.0 = Hex-STRING: 00 01 42 D0 67 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.1 = Hex-STRING: 00 01 42 D0 67 01
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.2 = Hex-STRING: 00 01 42 D0 67 02
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.3 = Hex-STRING: 00 01 42 D0 67 03
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.4 = Hex-STRING: 00 01 42 D0 67 04
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.5 = Hex-STRING: 00 01 42 D0 67 05
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.6 = Hex-STRING: 00 01 42 D0 67 06
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.7 = Hex-STRING: 00 01 42 D0 67 07
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.8 = Hex-STRING: 00 01 42 D0 67 08
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.9 = Hex-STRING: 00 01 42 D0 67 09
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.10 = Hex-STRING: 00 01 42 D0 67 0A
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.11 = Hex-STRING: 00 01 42 D0 67 0B
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.66.208.103.12 = Hex-STRING: 00 01 42 D0 67 0C
SNMPv2-SMI::mib-2.17.4.3.1.1.0.30.236.196.143.130 = Hex-STRING: 00 1E EC C4 8F 82
SNMPv2-SMI::mib-2.17.4.3.1.1.0.80.191.232.146.174 = Hex-STRING: 00 50 BF E8 92 AE
2. get the bridge port number for each vlan
snmpwalk -c public@1 -v2c 10.1.1.10 1.3.6.1.2.1.17.4.3.1.2
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.0 = INTEGER: 31
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.1 = INTEGER: 13
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.2 = INTEGER: 14
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.3 = INTEGER: 15
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.4 = INTEGER: 16
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.5 = INTEGER: 17
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.6 = INTEGER: 18
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.7 = INTEGER: 19
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.8 = INTEGER: 20
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.9 = INTEGER: 22
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.10 = INTEGER: 23
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.11 = INTEGER: 24
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.66.208.103.12 = INTEGER: 25
SNMPv2-SMI::mib-2.17.4.3.1.2.0.30.236.196.143.130 = INTEGER: 15
SNMPv2-SMI::mib-2.17.4.3.1.2.0.80.191.232.146.174 = INTEGER: 13
SNMPv2-SMI::mib-2.17.4.3.1.2.255.255.255.255.255.255 = INTEGER: 0
3. get bridge port number to ifindex mapping
snmpwalk -c public@1 -v2c 10.1.1.10 1.3.6.1.2.1.17.1.4.1.2
SNMPv2-SMI::mib-2.17.1.4.1.2.13 = INTEGER: 2
SNMPv2-SMI::mib-2.17.1.4.1.2.14 = INTEGER: 3
SNMPv2-SMI::mib-2.17.1.4.1.2.15 = INTEGER: 4
SNMPv2-SMI::mib-2.17.1.4.1.2.16 = INTEGER: 5
SNMPv2-SMI::mib-2.17.1.4.1.2.17 = INTEGER: 6
SNMPv2-SMI::mib-2.17.1.4.1.2.18 = INTEGER: 7
SNMPv2-SMI::mib-2.17.1.4.1.2.19 = INTEGER: 8
SNMPv2-SMI::mib-2.17.1.4.1.2.20 = INTEGER: 9
SNMPv2-SMI::mib-2.17.1.4.1.2.22 = INTEGER: 10
SNMPv2-SMI::mib-2.17.1.4.1.2.23 = INTEGER: 11
SNMPv2-SMI::mib-2.17.1.4.1.2.24 = INTEGER: 12
SNMPv2-SMI::mib-2.17.1.4.1.2.25 = INTEGER: 13
4. get the ifname
snmpwalk -c public@1 -v2c 10.1.1.10 1.3.6.1.2.1.31.1.1.1.1
IF-MIB::ifName.1 = STRING: VL1
IF-MIB::ifName.2 = STRING: Fa0/1
IF-MIB::ifName.3 = STRING: Fa0/2
IF-MIB::ifName.4 = STRING: Fa0/3
IF-MIB::ifName.5 = STRING: Fa0/4
IF-MIB::ifName.6 = STRING: Fa0/5
IF-MIB::ifName.7 = STRING: Fa0/6
IF-MIB::ifName.8 = STRING: Fa0/7
IF-MIB::ifName.9 = STRING: Fa0/8
IF-MIB::ifName.10 = STRING: Fa0/9
IF-MIB::ifName.11 = STRING: Fa0/10
IF-MIB::ifName.12 = STRING: Fa0/11
IF-MIB::ifName.13 = STRING: Fa0/12
IF-MIB::ifName.14 = STRING: Nu0
因此,在这种情况下,vlan 1 上的 2 个 mac 地址位于接口 Fa0/1 和 Fa0/3 上