簡介
本文檔介紹如何在SNMP v2和v3配置中的Nexus 5k、7k和9K中排除OID。
必要條件
需求
思科建議您在實施對象識別符號(OID)排除之前,瞭解以下主題:
- 熟悉簡單網路管理協定(SNMP)
- 訪問裝置配置模式
- 瞭解要排除的OID
- 瞭解SNMP社群和使用者組態
採用元件
本文檔中的資訊基於對以下Nexus型號進行的實驗室測試:
- Nexus 5k
- Nexus 7k
- Nexus 9k
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
背景資訊
在SNMP的世界中,您經常會遇到管理資訊庫(MIB)樹解析遇到障礙的情況,在特定OID處進入停頓,有時會導致視窗超時或類似問題。當對有問題的OID的連續輪詢觸發既不必要又無影響的警報時,會出現另一個常見問題。擺脫這些型別的情形的一種可能方法是建立排除,指示裝置跳過該特定OID並繼續執行MIB結構的其餘部分。通過引導裝置繞過有問題的OID並繼續執行MIB結構的其餘部分,可以促進MIB樹的平滑流動。
注意:必須注意的是,此排除項可能會影響我們從MIB樹讀取資料的方式。在繼續這些排除之前,請謹慎並確保OID的必要性。
雖然排除OID通常在聚合服務路由器(ASR)/Catalyst交換機(CAT)/整合服務路由器(ISR)等裝置中追求簡單流程,但由於缺少檢視,在Nexus裝置中導航這一挑戰顯得更為複雜。通過引入角色並將其對映至社群/使用者,本文深入探討了一種創新方法,提出了在Nexus 5k、7k和9K裝置上的SNMP v2和v3配置中排除OID的解決方案。
基本步驟
訪問配置模式:
#conf t
定義OID排除的角色:
#role name
#rule 1 permit read feature snmp #rule 2 deny {read/ read-write} oid
提示: {read/read/write}允許您在「讀取」和「讀取/寫入」SNMP操作之間進行選擇。「讀取」操作通常涉及檢索資訊,而「讀取/寫入」操作同時涉及檢索和修改資訊。您可以根據自己的偏好選擇讀取/讀取/寫入。
離開組態設定模式:
#exit
將組態套用到SNMP社群/使用者。
對於SNMPv2:
#snmp-server community
group
對於SNMPv3:
#snmp-server user
auth {sha/md5}
priv {aes/des}
組態
註:此示例包括OID 1.3.6.1.2.1.2.2.1.3(ifType)的排除。確保將ifType OID替換為要排除的ifType OID。
定義要排除OID ifType的角色:
switch#
switch# config t
Enter configuration commands, one per line. End with CNTL/Z.
switch(config)# role name deny_oid
switch(config-role)# rule 1 permit read feature snmp
switch(config-role)# rule 2 deny read oid 1.3.6.1.2.1.2.2.1.3
switch(config-role)# exit
switch(config)# exit
switch# sh role name deny_oid
Role: deny_oid
Description: new role
Vlan policy: permit (default)
Interface policy: permit (default)
Vrf policy: permit (default)
-------------------------------------------------------------------
Rule Perm Type Scope Entity
-------------------------------------------------------------------
2 deny read oid 1.3.6.1.2.1.2.2.1.3
1 permit read feature snmp
switch#
建立具有角色的SNMPvdeny_oid
2社群:
switch(config)# snmp-server community snmpv2user group deny_oid
switch(config)# exit
switch# sh snmp community
Community Group / Access context acl_filter
_________ ______________ _______ __________
snmpv2user deny_oid
switch#
正在建立具有deny_oid角色的SNMPv3使用者:
switch# config t
Enter configuration commands, one per line. End with CNTL/Z.
switch(config)# snmp-server user snmpv3user deny_oid auth sha password!123 priv ?
WORD Privacy password for user (Max Size 134)
switch(config)# snmp-server user snmpv3user deny_oid auth sha password!123 priv password!123
switch(config)# do sh snmp user
______________________________________________________________
SNMP USERS
______________________________________________________________
User Auth Priv(enforce) Groups acl_filter
____ ____ _____________ ______ __________
admin md5 aes-128(no) network-admin
snmpv3user sha aes-128(no) deny_oid
______________________________________________________________
NOTIFICATION TARGET USERS (configured for sending V3 Inform)
______________________________________________________________
User Auth Priv
___ ____ ____
switch(config)#
驗證
註:測試使用者「trial」用於檢查ifType OID的輪詢。其餘使用者使用deny_oid角色進行對映,並且未顯示ifType OID的任何資料,如圖所示。
無排除的SNMPwalk:
註:全文中使用a.b.c.d來代替裝置的IP地址。
[root@user ~]# snmpwalk -v2c -c trial a.b.c.d 1.3.6.1.2.1.2.2.1.3
IF-MIB::ifType.83886080 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436207616 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436208128 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436208640 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436209152 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436209664 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436210176 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436210688 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436211200 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436211712 = INTEGER: ethernetCsmacd(6)
^C
具有已排除OID的SNMPv2的SNMPwalk:
[root@user ~]# snmpwalk -v2c -c snmpv2user a.b.c.d 1.3.6.1.2.1.2.2.1.3
IF-MIB::ifType = No Such Object available on this agent at this OID
注意:已建立一個新使用者「trialv3」以演示不排除OID的輪詢。
不排除OID的SNMPwalk:
[root@user ~]# snmpwalk -v3 -u trialv3 -l authPriv -a sha -A 'password!123' -x aes -X 'password!123' a.b.c.d 1.3.6.1.2.1.2.2.1.3
IF-MIB::ifType.83886080 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436207616 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436208128 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436208640 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436209152 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436209664 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436210176 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436210688 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436211200 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436211712 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.436212224 = INTEGER: ethernetCsmacd(6)
^C
[root@user ~]#
具有已排除OID的SNMPv3使用者的SNMPwalk:
[root@user ~]# snmpwalk -v3 -u snmpv3user -l authPriv -a sha -A 'password!123' -x aes -X 'password!123' a.b.c.d 1.3.6.1.2.1.2.2.1.3
IF-MIB::ifType = No Such Object available on this agent at this OID
[root@user ~]#