| ライター翻訳版 - December 24, 2003 |
| 機械翻訳版 - October 26, 2005 |
| 英語版 - October 26, 2005 |
| Document ID: 44800 |
目次
概要
はじめに
表記法
前提条件
使用するコンポーネント
背景説明
MIB 変数(オブジェクト識別子(OID)を含む)の詳細
MAC アドレスが判明しているポート番号の取得
手順説明
関連情報
概要
この文書では、Simple Network Management Protocol(SNMP; 簡易ネットワーク管理プロトコル)を使って、MAC アドレスが判明している Catalyst スイッチのポート番号を取得する方法について説明します。
はじめに
表記法
文書表記の詳細は、「シスコ テクニカル ティップスの表記法」を参照してください。
前提条件
この文書の読者は次の項目に関する知識が必要です。
-
SNMP を使って、Catalyst スイッチから VLAN を取得する方法
-
SNMP を使って、コミュニティ ストリング インデックスを使用する方法
-
SNMP の get コマンドと walk コマンドの使用方法
使用するコンポーネント
この文書は、BRIDGE-MIB と IF-MIB をサポートしている通常の Catalyst OS または Catalyst IOS を実行している Catalyst スイッチに適用されます。この文書の情報は、次のソフトウェアとハードウェアのバージョンに基づいています。
-
CatIOS 12.0(5)WC5a を実行している Catalyst 3524XL
-
NET-SNMP バージョン 5.0.6 は、http://www.net-snmp.org/ で入手できます。
この文書で紹介する情報は、特定の実験環境にあるデバイスを使用して作成されました。この文書で使用するすべてのデバイスは、クリアな状態(デフォルト)から設定作業を始めています。実稼動中のネットワークで作業する場合は、コマンドの実行によって生じる影響について、事前に理解しておいてください。
背景説明
CAM テーブル、VLAN、および関連する MIB(CISCO-VTP-MIB、BRIDGE-MIB など)のクエリー方法の詳細については、「SNMP を使った、Catalyst スイッチのダイナミック CAM エントリ(CAM テーブル)の取得方法」の「背景説明」のセクションを参照してください。
MIB 変数(オブジェクト識別子(OID)を含む)の詳細
.1.3.6.1.2.1.17.4.3.1.1
dot1dTpFdbAddress OBJECT-TYPE
-- FROM BRIDGE-MIB
-- TEXTUAL CONVENTION MacAddress
SYNTAX OCTET STRING (6)
MAX-ACCESS read-only
STATUS Mandatory
DESCRIPTION "A unicast MAC address for which the bridge has forwarding and/or filtering information."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) dot1dBridge(17) dot1dTp(4)
dot1dTpFdbTable(3) dot1dTpFdbEntry(1) 1 }
.1.3.6.1.2.1.17.4.3.1.2
dot1dTpFdbPort OBJECT-TYPE
-- FROM BRIDGE-MIB
SYNTAX Integer
MAX-ACCESS read-only
STATUS Mandatory
DESCRIPTION "Either the value "0", or the port number of the port on which a frame having a source
address equal to the value of the corresponding instance of dot1dTpFdbAddress has been seen.
A value of "0" indicates that the port number has not been learned, but that the bridge does
have some forwarding/filtering information about this address (that is, in the StaticTable).
Implementors are encouraged to assign the port value to this object whenever it is
learned, even for addresses for which the corresponding value of dot1dTpFdbStatus is not learned(3)."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) dot1dBridge(17) dot1dTp(4)
dot1dTpFdbTable(3) dot1dTpFdbEntry(1) 2 }
.1.3.6.1.2.1.2.2.1.1
ifIndex OBJECT-TYPE
SYNTAX InterfaceIndex
MAX-ACCESS read-only
STATUS current
DESCRIPTION "A unique value, greater than zero, for each interface. It
is recommended that values are assigned contiguously
starting from 1. The value for each interface sub-layer
must remain constant at least from one re-initialization of
the entity's network management system to the next re-
initialization."
::= { ifEntry 1 }
.1.3.6.1.2.1.17.1.4.1.2 dot1dBasePortIfIndex OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The value of the instance of the ifIndex object,
defined in MIB-II, for the interface corresponding
to this port."
::= { dot1dBasePortEntry 2 }
.1.3.6.1.2.1.31.1.1.1.1
ifName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION "The textual name of the interface. The value of this
object should be the name of the interface as assigned by
the local device and should be suitable for use in commands
entered at the device's `console'. This might be a text
name, such as `le0' or a simple port number, such as `1',
depending on the interface naming syntax of the device. If
several entries in the ifTable together represent a single
interface as named by the device, then each will have the
same value of ifName. Note that for an agent which responds
to SNMP queries concerning an interface on some other
(proxied) device, then the value of ifName for such an
interface is the proxied device's local name for it.
If there is no local name, or this object is otherwise not
applicable, then this object contains a zero-length string."
::= { ifXEntry 1 }
MAC アドレスが判明しているポート番号の取得
手順説明
次の手順に従い、SNMP を使って、MAC アドレスが判明しているポート番号を取得します。 次の手順のコマンド出力では、最終的に斜体の値が使われます。
-
public は、読み取り用コミュニティ ストリングです。
-
@1 は、読み取り用コミュニティ ストリングの VLAN 1 部分です。
-
crumpy は、デバイス ホスト名です(ここでは ipaddress も使用できます)。
-
この例では、(コミュニティ ストリング インデックスを使って)MAC アドレス テーブル dot1dTpFdbAddress (1.3.6.1.2.1.17.4.3.1.1) を取得するため、VLAN 1 を使用します。 これにより、VLAN 1 に属しているすべてのポート上で判明している MAC アドレスが一覧表示されます。
snmpwalk -c public@1 crumpy .1.3.6.1.2.1.17.4.3.1.1 17.4.3.1.1.0.0.12.7.172.8 = Hex: 00 00 0C 07 AC 08 17.4.3.1.1.0.1.2.27.80.145 = Hex: 00 01 02 1B 50 91 17.4.3.1.1.0.1.3.72.77.90 = Hex: 00 01 03 48 4D 5A 17.4.3.1.1.0.1.3.72.221.191 = Hex: 00 01 03 48 DD BF …
NMS に MIB がロードされている場合は、オブジェクト名を使用することもできます。
snmpwalk -c public@1 crumpy dot1dTpFdbAddress
注: 次の手順では、オブジェクト名も使用できます。
-
ここでは、VLAN 1 のブリッジ ポート番号を取得します。次の例に示すように、dot1dTpFdbPort (1.3.6.1.2.1.17.4.3.1.2) のクエリーを実行します。
snmpwalk -c public@1 crumpy .1.3.6.1.2.1.17.4.3.1.2 17.4.3.1.2.0.0.12.7.172.8 = 13 17.4.3.1.2.0.1.2.27.80.128 = 13 17.4.3.1.2.0.1.2.27.80.145 = 13 17.4.3.1.2.0.1.2.163.145.225 = 13 …
-
VLAN 1 のブリッジ ポート番号がわかったら、ifIndex (.1.3.6.1.2.1.2.2.1.1) にマッピングされているブリッジ ポートを取得します。 この作業を実行するには、次に示すように、dot1dBasePortIfIndex (.1.3.6.1.2.1.17.1.4.1.2) のクエリーを実行します。
snmpwalk -c public@1 crumpy .1.3.6.1.2.1.17.1.4.1.2 17.1.4.1.2.13 = 2 17.1.4.1.2.14 = 3 17.1.4.1.2.15 = 4 17.1.4.1.2.16 = 5
-
ifIndex が判明したら、上記手順で取得した ifIndex の値を、次に示すように適切なポート名に関連付けられるように、ifName (.1.3.6.1.2.1.31.1.1.1.1) に対して walk を実行する必要があります。
snmpwalk -c public@1 crumpy .1.3.6.1.2.1.31.1.1.1.1 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.1 = VL1 ifMIB.ifMIBObjects.ifXTable.ifXEntry. ifName.2 = Fa0/1 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.3 = Fa0/2 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.4 = Fa0/3 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.5 = Fa0/4 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.6 = Fa0/5 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.7 = Fa0/6 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.8 = Fa0/7 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.9 = Fa0/8 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.10 = Fa0/9 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.11 = Fa0/10 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.12 = Fa0/11 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.13 = Fa0/12 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.14 = Fa0/13 ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.15 = Fa0/14 … -
これで、次のように、MAC アドレスを判明したポートにリンクできます。
-
ステップ 1 から、MAC アドレスが次のように判明します。
17.4.3.1.1.0.0.12.7.172.8 = Hex: 00 00 0C 07 AC 08 -
ステップ 2 から、MAC アドレス (00 00 0C 07 AC 08) を通知したブリッジ ポートが、ブリッジ ポート 13 に属していることが判明します。
13 17.4.3.1.2.0.0.12.7.172.8 = 13 -
ステップ 3 から、ブリッジ ポート 13 の ifIndex 番号が 2 であることが判明します。
17.1.4.1.2.13 = 2
-
ステップ 4 から、ifIndex 2 はファースト イーサネット 0/1 ポートに対応していることがわかります。
ifMIB.ifMIBObjects.ifXTable.ifXEntry.ifName.2 = Fa0/1
結論: MAC アドレス 00 00 0C 07 AC 08 は、Fa0/1 上にあることが判明します。
CatOS スイッチに対する show cam dynamic コマンド出力からの出力、または CatIOS スイッチに対する show mac コマンド出力からの出力と、これを比較します。
crumpy#sh mac Dynamic Address Count: 58 Secure Address Count: 2 Static Address (User-defined) Count: 0 System Self Address Count: 51 Total MAC addresses: 111 Maximum MAC addresses: 8192 Non-static Address Table: Destination Address Address Type VLAN Destination Port ------------------- ------------ ---- ------------------- 0000.0c07.ac08 Dynamic 1 FastEthernet0/1 0001.021b.5091 Dynamic 1 FastEthernet0/1 0001.0348.4d5a Dynamic 1 FastEthernet0/1 0001.0348.ddbf Dynamic 1 FastEthernet0/1 0001.972d.dfae Dynamic 1 FastEthernet0/1 0002.55c6.cfe7 Dynamic 1 FastEthernet0/1 0002.7d61.d400 Dynamic 1 FastEthernet0/1 …
-
