火曜日, 7月 10, 2012

Cisco portとMacアドレスを紐づける方法


Cisco portとMacアドレスを紐づける方法を、snmpwalkで解決する方法です。
正しいマニュアルはciscoにもありますのでそちらもご参照ください。


まあ、自分のための備忘録です^^



【参考】
Cisco SNMP を使った、Catalyst スイッチの MAC アドレスからのポート番号の検索
http://www.cisco.com/cisco/web/support/JP/100/1007/1007897_mactoport44800-j.html


【概要】
ブリッジポート番号とMacアドレス一覧を取得する
snmpwalk -v 1 -c コミュ名 ホスト 1.3.6.1.2.1.17.4.3.1.1 
ブリッジポート番号とMIB番号を取得する
snmpwalk -v 1 -c コミュ名 ホスト 1.3.6.1.2.1.17.4.3.1.2 
MIB番号とブリッジ ポートを取得する
snmpwalk -v 1 -c コミュ名 ホスト 1.3.6.1.2.1.17.1.4.1.2 
最後にブリッジ ポートからインターフェイス名(ポート番号)を一致させる
snmpwalk -v 1 -c コミュ名 ホスト 1.3.6.1.2.1.31.1.1.1.1


【作業例】
※セキュリティのため、MACアドレスは00 00 00 00 00 00に書き換えています。

---
[Manaka@Server ~]$ snmpwalk -v 1 -c コミュ名 host 1.3.6.1.2.1.17.4.3.1.1
SNMPv2-SMI::mib-2.17.4.3.1.1.0.0.12.7.172.1 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.215.111.53.67 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.1.215.111.115.195 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.25.223 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.52.146 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.53.20 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.53.150 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.54.204 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.29.9.107.55.53 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.30.201.181.16.158 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.31.39.162.79.12 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.31.39.162.79.24 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.34.25.186.26.147 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.54.169.85 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.54.172.197 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.58.117.190 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.58.121.56 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.58.125.34 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.58.128.166 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.0.38.185.58.136.173 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.60.223.30.15.244.64 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.60.223.30.204.9.151 = Hex-STRING: 00 00 00 00 00 00
SNMPv2-SMI::mib-2.17.4.3.1.1.60.223.30.204.9.192 = Hex-STRING: 00 00 00 00 00 00
[Manaka@Server ~]$
[Manaka@Server ~]$ snmpwalk -v 1 -c コミュ名 host 1.3.6.1.2.1.17.4.3.1.2
SNMPv2-SMI::mib-2.17.4.3.1.2.0.0.12.7.172.1 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.215.111.53.67 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.0.1.215.111.115.195 = INTEGER: 25
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.25.223 = INTEGER: 2
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.52.146 = INTEGER: 3
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.53.20 = INTEGER: 5
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.53.150 = INTEGER: 4
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.54.204 = INTEGER: 1
SNMPv2-SMI::mib-2.17.4.3.1.2.0.29.9.107.55.53 = INTEGER: 7
SNMPv2-SMI::mib-2.17.4.3.1.2.0.30.201.181.16.158 = INTEGER: 11
SNMPv2-SMI::mib-2.17.4.3.1.2.0.31.39.162.79.12 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.0.31.39.162.79.24 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.0.31.39.162.79.64 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.0.34.25.186.26.147 = INTEGER: 13
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.54.169.85 = INTEGER: 18
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.54.172.197 = INTEGER: 17
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.58.117.190 = INTEGER: 22
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.58.121.56 = INTEGER: 21
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.58.125.34 = INTEGER: 6
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.58.128.166 = INTEGER: 19
SNMPv2-SMI::mib-2.17.4.3.1.2.0.38.185.58.136.173 = INTEGER: 20
SNMPv2-SMI::mib-2.17.4.3.1.2.60.223.30.15.244.64 = INTEGER: 56
SNMPv2-SMI::mib-2.17.4.3.1.2.60.223.30.204.9.151 = INTEGER: 64
SNMPv2-SMI::mib-2.17.4.3.1.2.60.223.30.204.9.192 = INTEGER: 64
[Manaka@Server ~]$
[Manaka@Server ~]$ snmpwalk -v 1 -c コミュ名 host 1.3.6.1.2.1.17.1.4.1.2
SNMPv2-SMI::mib-2.17.1.4.1.2.1 = INTEGER: 10001
SNMPv2-SMI::mib-2.17.1.4.1.2.2 = INTEGER: 10002
SNMPv2-SMI::mib-2.17.1.4.1.2.3 = INTEGER: 10003
SNMPv2-SMI::mib-2.17.1.4.1.2.4 = INTEGER: 10004
SNMPv2-SMI::mib-2.17.1.4.1.2.5 = INTEGER: 10005
SNMPv2-SMI::mib-2.17.1.4.1.2.6 = INTEGER: 10006
SNMPv2-SMI::mib-2.17.1.4.1.2.7 = INTEGER: 10007
SNMPv2-SMI::mib-2.17.1.4.1.2.8 = INTEGER: 10008
SNMPv2-SMI::mib-2.17.1.4.1.2.9 = INTEGER: 10009
SNMPv2-SMI::mib-2.17.1.4.1.2.10 = INTEGER: 10010
SNMPv2-SMI::mib-2.17.1.4.1.2.11 = INTEGER: 10011
SNMPv2-SMI::mib-2.17.1.4.1.2.13 = INTEGER: 10013
SNMPv2-SMI::mib-2.17.1.4.1.2.15 = INTEGER: 10015
SNMPv2-SMI::mib-2.17.1.4.1.2.16 = INTEGER: 10016
SNMPv2-SMI::mib-2.17.1.4.1.2.17 = INTEGER: 10017
SNMPv2-SMI::mib-2.17.1.4.1.2.18 = INTEGER: 10018
SNMPv2-SMI::mib-2.17.1.4.1.2.19 = INTEGER: 10019
SNMPv2-SMI::mib-2.17.1.4.1.2.20 = INTEGER: 10020
SNMPv2-SMI::mib-2.17.1.4.1.2.21 = INTEGER: 10021
SNMPv2-SMI::mib-2.17.1.4.1.2.22 = INTEGER: 10022
SNMPv2-SMI::mib-2.17.1.4.1.2.23 = INTEGER: 10023
SNMPv2-SMI::mib-2.17.1.4.1.2.25 = INTEGER: 10101
SNMPv2-SMI::mib-2.17.1.4.1.2.26 = INTEGER: 10102
SNMPv2-SMI::mib-2.17.1.4.1.2.56 = INTEGER: 5001
SNMPv2-SMI::mib-2.17.1.4.1.2.64 = INTEGER: 5002
[Manaka@Server ~]$
[Manaka@Server ~]$ snmpwalk -v 1 -c コミュ名 host 1.3.6.1.2.1.31.1.1.1.1
IF-MIB::ifName.1 = STRING: Vl1
IF-MIB::ifName.5001 = STRING: Po1
IF-MIB::ifName.5002 = STRING: Po2
IF-MIB::ifName.10001 = STRING: Fa0/1
IF-MIB::ifName.10002 = STRING: Fa0/2
IF-MIB::ifName.10003 = STRING: Fa0/3
IF-MIB::ifName.10004 = STRING: Fa0/4
IF-MIB::ifName.10005 = STRING: Fa0/5
IF-MIB::ifName.10006 = STRING: Fa0/6
IF-MIB::ifName.10007 = STRING: Fa0/7
IF-MIB::ifName.10008 = STRING: Fa0/8
IF-MIB::ifName.10009 = STRING: Fa0/9
IF-MIB::ifName.10010 = STRING: Fa0/10
IF-MIB::ifName.10011 = STRING: Fa0/11
IF-MIB::ifName.10012 = STRING: Fa0/12
IF-MIB::ifName.10013 = STRING: Fa0/13
IF-MIB::ifName.10014 = STRING: Fa0/14
IF-MIB::ifName.10015 = STRING: Fa0/15
IF-MIB::ifName.10016 = STRING: Fa0/16
IF-MIB::ifName.10017 = STRING: Fa0/17
IF-MIB::ifName.10018 = STRING: Fa0/18
IF-MIB::ifName.10019 = STRING: Fa0/19
IF-MIB::ifName.10020 = STRING: Fa0/20
IF-MIB::ifName.10021 = STRING: Fa0/21
IF-MIB::ifName.10022 = STRING: Fa0/22
IF-MIB::ifName.10023 = STRING: Fa0/23
IF-MIB::ifName.10024 = STRING: Fa0/24
IF-MIB::ifName.10101 = STRING: Gi0/1
IF-MIB::ifName.10102 = STRING: Gi0/2
IF-MIB::ifName.10501 = STRING: Nu0
[Manaka@Server ~]$
---