Cisco

cisco 2900xl - SNMP - 獲取連接到介面的設備的 MAC 地址

  • January 11, 2011

基本上我想做的是找出插入交換機介面的設備的mac地址是什麼(例如FastEthernet0 / 1)

通過閱讀交換機文件,我發現我可以在其上配置 snmp 陷阱,以使其通知交換機通過使用命令檢測到的任何新 MAC 地址

snmp-server 啟用陷阱 mac-notifiction

但由於某種原因,我的交換機不支持此功能。我看到的唯一選擇是

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。

我能得到的任何幫助都會非常感激!

這是我的交換機上“顯示版本”的輸出

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

我不確定 2900/IOS 12.0 是否支持它,但您可以嘗試瀏覽 dot1dTpFdbPort (.1.3.6.1.2.1.17.4.3.1.2) 您需要使用特殊的社區字元串,包括您想要的 vlan獲取mac地址表:community@vlan_number 所以如果你的交換機是1.2.3.4,使用community snmpro並且有vlan 30,試試這個:

snmpwalk -v2c -c snmpro@30 1.2.3.4 1.3.6.1.2.1.17.4.3.1.2

半徑,感謝您為我指明正確的方向。根據您的建議搜尋了一下,我想我現在有了。

對於其他可能需要它的人,這就是程序….

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 上

引用自:https://serverfault.com/questions/220828