简介
本文档介绍如何在SNMP v2和v3配置中排除Nexus 5k、7k和9K中的OID。
先决条件
要求
Cisco建议您在实施对象标识符(OID)排除之前了解以下主题:
- 熟悉简单网络管理协议(SNMP)
- 访问设备配置模式
- 了解要排除的OID
- 了解SNMP社区和用户配置
使用的组件
本文档中的信息基于对以下Nexus型号进行的实验室测试:
- Nexus 5k
- Nexus 7k
- Nexus 9k
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
背景信息
在SNMP世界中,您经常遇到管理信息库(MIB)树解析遇到障碍的情况,在特定OID处进入停滞状态,有时会导致窗口超时或类似问题。当对有问题的OID的持续轮询触发既不必要也不有效的警报时,会产生另一个常见挑战。一种可能的消除此类情况的方法是创建例外项,指示设备跳过该特定OID并继续执行MIB结构的其余部分。通过引导设备绕过有问题的OID并继续执行MIB结构的其余部分,您可以促进MIB树的平滑流动。
注:必须注意的是,此排除可能会影响我们从MIB树读取数据的方式。在继续这些排除之前,请谨慎并确保有必要使用OID。
在聚合服务路由器(ASR)/Catalyst交换机(CAT)/集成服务路由器(ISR)等设备中,排除OID通常追求简单明了的过程,但是在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 ~]#