snmp Oid整理與運用

OID常用組

管理信息庫MIB:任何一個被管理的資源都表示成一個對象,稱爲被管理的對象。MIB是被管理對象的集合。它定義了被管理對象的一系列屬性:對象的名稱、對象的訪問權限和對象的數據類型等。每個SNMP設備(Agent)都有自己的MIB。MIB也可以看作是NMS(網管系統)和Agent之間的溝通橋樑。

MIB文件中的變量使用的名字取自ISO和ITU管理的對象標識符(objectidentifier)名字空間。它是一種分級樹的結構。如圖2所示,第一級有三個節點:ccitt、iso、iso-ccitt。低級的對象ID分別由相關組織分配。一個特定對象的標識符可通過由根到該對象的路徑獲得。一般網絡設備取iso節點下的對象內容。如名字空間ip結點下一個名字爲ipInReceives的MIB變量被指派數字值3,因而該變量的名字爲:iso.org.dod.internet.mgmt.mib.ip.ipInReceives相應的數字表示(對象標識符OID,唯一標識一個MIB對象)爲:1.3.6.1.2.1.4.3

MIB樹

mib_tree

ip組

oid: .1.3.6.1.2.1.4

1. ipRouteTable表

oid: .1.3.6.1.2.1.4.21

DEll 沒有這個oid

例子:

iso.org.dod.internet.mgmt.mib.ip. ipRouteTable.ipRouteEntry.ipRouteNextHop.202.120.86.71,

1.3.6.1.2.1.4.21.1.7.202.120.86.71

ipRouteEntry

IpRouteDest

oid = 1.3.6.1.2.1.4.21.1.1

    IP-MIB::ip.21.1.1.0.0.0.0 = IpAddress: 0.0.0.0
    IP-MIB::ip.21.1.1.10.10.4.0 = IpAddress: 10.10.4.0
    IP-MIB::ip.21.1.1.10.10.4.236 = IpAddress: 10.10.4.236
    IP-MIB::ip.21.1.1.10.10.4.255 = IpAddress: 10.10.4.255
    IP-MIB::ip.21.1.1.127.0.0.0 = IpAddress: 127.0.0.0
    IP-MIB::ip.21.1.1.127.0.0.1 = IpAddress: 127.0.0.1
    IP-MIB::ip.21.1.1.127.255.255.255 = IpAddress: 127.255.255.255
    IP-MIB::ip.21.1.1.255.255.255.255 = IpAddress: 255.255.255.255
IpRouteNextHop
oid =   `.1.3.6.1.2.1.4.21.1.7`
IP-MIB::ip.21.1.7.0.0.0.0 = IpAddress: 10.10.4.254
    IP-MIB::ip.21.1.7.10.10.4.0 = IpAddress: 10.10.4.236
    IP-MIB::ip.21.1.7.10.10.4.236 = IpAddress: 127.0.0.1
    IP-MIB::ip.21.1.7.10.10.4.255 = IpAddress: 127.0.0.1
    IP-MIB::ip.21.1.7.127.0.0.0 = IpAddress:127.0.0.1
    IP-MIB::ip.21.1.7.127.0.0.1 = IpAddress: 127.0.0.1
    IP-MIB::ip.21.1.7.127.255.255.255 = IpAddress: 127.0.0.1
    IP-MIB::ip.21.1.7.255.255.255.255 = IpAddress: 127.0.0.1
IpRouteMask
oid =   `.1.3.6.1.2.1.4.21.1.11`
    IP-MIB::ip.21.1.11.0.0.0.0 = IpAddress: 0.0.0.0
    IP-MIB::ip.21.1.11.10.10.4.0 = IpAddress: 255.255.255.0
    IP-MIB::ip.21.1.11.10.10.4.236 = IpAddress: 255.255.255.255
    IP-MIB::ip.21.1.11.10.10.4.255 = IpAddress: 255.255.255.255
    IP-MIB::ip.21.1.11.127.0.0.0 = IpAddress: 255.0.0.0
    IP-MIB::ip.21.1.11.127.0.0.1 = IpAddress: 255.255.255.255
    IP-MIB::ip.21.1.11.127.255.255.255 = IpAddress: 255.255.255.255
    IP-MIB::ip.21.1.11.255.255.255.255 = IpAddress: 255.255.255.255
IpRouteType

oid = 1.3.6.1.2.1.4.21.1.8

IP-MIB::ip.21.1.8.0.0.0.0 = INTEGER: 3
IP-MIB::ip.21.1.8.10.10.4.0 = INTEGER: 3
IP-MIB::ip.21.1.8.10.10.4.243 = INTEGER: 3
IP-MIB::ip.21.1.8.10.10.4.255 = INTEGER: 3
IP-MIB::ip.21.1.8.127.0.0.0 = INTEGER: 3
IP-MIB::ip.21.1.8.127.0.0.1 = INTEGER: 3
IP-MIB::ip.21.1.8.127.255.255.255 = INTEGER: 3
IP-MIB::ip.21.1.8.255.255.255.255 = INTEGER: 3

2. ipAddrTable表

3. ipNetToMediaTable表

System組

Interfaces組

.1.3.6.1.2.1.2

  • ifDescr 端口描述

OID = .1.3.6.1.2.1.2.2.1.2

  • ifSpeed 端口速率

  • ifInOctets端口進出流量

  • 等等...

oid的使用

以華三V7爲例:

qsnmpwalk 10.11.254.1 sysDescr

SNMPv2-MIB::sysDescr.0 = STRING: H3C Comware Platform Software, Software Version 7.1.070, Release 2510P01
H3C S6800-54QT
Copyright (c) 2004-2017 New H3C Technologies Co., Ltd. All rights reserved.

查詢某個端口下的MAC地址

得到交換機具體端口下的MAC地址。

掃描MAC表(私有MIB)

得到MAC地址與PortInterger的對應關係

qsnmpwalk 10.11.254.1 1.3.6.1.2.1.17.7.1.2.2.1.2

SNMPv2-SMI::mib-2.17.7.1.2.2.1.2.1000.88.105.108.194.51.215 = INTEGER: 1613
SNMPv2-SMI::mib-2.17.7.1.2.2.1.2.1000.88.105.108.194.131.239 = INTEGER: 1613
...

掃描PortInteger表(私有MIB)

得到PortInterger與IfIndex的對應關係

qsnmpwalk 10.11.254.1 1.3.6.1.2.1.17.1.4.1.2

SNMPv2-SMI::mib-2.17.1.4.1.2.1 = INTEGER: 1
SNMPv2-SMI::mib-2.17.1.4.1.2.2 = INTEGER: 2
...
SNMPv2-SMI::mib-2.17.1.4.1.2.1613 = INTEGER: 1619

掃描ifDescr表

得到IfIndex與ifDescr的對應關係

IF-MIB::ifDescr.1 = STRING: Ten-GigabitEthernet1/0/1
IF-MIB::ifDescr.2 = STRING: Ten-GigabitEthernet1/0/2
...
IF-MIB::ifDescr.1613 = STRING: NULL0
IF-MIB::ifDescr.1619 = STRING: Bridge-Aggregation1

最終對應關係:

Bridge-Aggregation1 - 1619 - 1613 - 一堆mac
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章