配置 SNMPv3
SNMP 版本 3 (SNMPv3) 通过支持用户身份验证和数据加密,增强了 SNMPv1 和 SNMPv2c 的功能。SNMPv3 使用基于用户的安全模型 (USM) 来确保 SNMP 消息的安全通信,并使用基于视图的访问控制模型 (VACM) 来管理用户访问控制。
SNMPv3 功能包括:
-
使用 USM,SNMP 管理器和代理之间的 SNMP 消息可以对消息源进行身份验证并检查数据完整性。USM 通过强制实施超时限制和检查重复的邮件请求 ID 来减少邮件延迟和邮件重播。
-
VACM 通过为对代理的 SNMP 查询提供用户访问控制来补充 USM。您可以定义要扩展到一个或多个用户的组的访问权限。访问权限由安全模型参数(
usm、v1或v2)和安全级别参数(authentication、privacy或none)确定。对于每个安全级别,必须为组关联一个 MIB 视图。将 MIB 视图与组关联可授予对该组的一组 MIB 对象的读取、写入或通知权限。 -
您可以为每个用户配置安全参数,包括用户名、身份验证类型和身份验证密码,以及隐私类型和隐私密码。提供给每个用户的用户名的格式取决于为该用户配置的安全模型。
-
为了确保消息传递安全,在本地 SNMP 服务器和目标 SNMP 服务器之间发送的消息传递数据中包含另一种类型的用户名(称为安全名称)。每个用户名都映射到一个安全名称,但安全名称的格式与安全模型无关。
-
SNMPv3 中的陷阱条目是通过配置通知、通知过滤器、目标地址和目标参数创建的。该
notify语句指定通知的类型(陷阱),并包含一个标签,用于定义一组接收陷阱的目标地址。通知过滤器定义对陷阱对象标识符 (OID) 集合的访问。目标地址定义 SNMP 管理应用程序的地址和用于发送通知的其他属性。目标参数定义用于向特定目标发送通知的消息处理和安全参数。
要配置 SNMPv3,请执行以下操作:
SNMPv3 通过将 USM 与身份验证和加密密钥结合使用,确保增强 SNMP 消息的安全性。因此,在使用 SNMPv3 查询路由器或交换机时,无需限制外部计算机。因此,Junos OS 或 Junos OS 演化版上的 SNMPv3 配置不支持客户端列表的访问限制。
但是,SNMPv2 确实需要使用客户端列表来允许特定客户端计算机发送 SNMP 查询,因为它依赖于基于社区字符串的访问。
创建 SNMPv3 用户
对于每个 SNMPv3 用户,您可以指定用户名、身份验证类型、身份验证密码、隐私类型和隐私密码。用户输入密码后,将生成基于引擎 ID 和密码的密钥并将其写入配置文件。生成密钥后,您可以从此配置文件中删除密码。
您只能为每个 SNMPv3 用户配置一种加密类型。
要创建用户,请在层次结构级别包含 user 语句 [edit snmp v3 usm local-engine] 。
要配置用户身份验证和加密,请在层次结构级别包含以下语句 [edit snmp v3 usm local-engine user username] 。
运行 Junos OS 的设备上的最低 SNMPv3 配置
要配置 SNMPv3 的最低要求,请在 和 [edit snmp] 层次结构级别包含[edit snmp v3]以下语句。
您必须在 [edit snmp view-name] 层次结构级别配置至少一个视图(通知、读取或写入)。
另请参阅
示例:SNMPv3 配置
定义 SNMPv3 配置:
[edit snmp]
engine-id {
use-mac-address;
}
view jnxAlarms {
oid 1.3.6.1.4.1.2636.3.4 include;
}
view interfaces {
oid 1.3.6.1.2.1.2 include;
}
view ping-mib {
oid 1.3.6.1.2.1.80 include;
}
[edit snmp v3]
notify n1 {
tag router1; # Identifies a set of target addresses
type trap;# Defines type of notification
}
notify n2 {
tag host1;
type trap;
}
notify-filter nf1 {
oid .1 include; # Defines which traps to send
} # In this case, includes all traps
notify-filter nf2 {
oid 1.3.6.1.4.1 include; # Sends enterprise-specific traps only
}
notify-filter nf3 {
oid 1.3.6.1.2.1.1.5 include; # Sends BGP traps only
}
snmp-community index1 {
community-name "$9$JOZi.QF/AtOz3"; # SECRET-DATA
security-name john; # Matches the security name at the target parameters
tag host1; # Finds the addresses that are allowed to be used with
}
target-address ta1 {# Associates the target address with the group
# san-francisco.
address 10.1.1.1;
address-mask 255.255.255.0; # Defines the range of addresses
port 162;
tag-list router1;
target-parameters tp1; # Applies configured target parameters
}
target-address ta2 {
address 10.1.1.2;
address-mask 255.255.255.0;
port 162;
tag-list host1;
target-parameters tp2;
}
target-address ta3 {
address 10.1.1.3;
address-mask 255.255.255.0;
port 162;
tag-list “router1 host1”;
target-parameters tp3;
}
target-parameters tp1 { # Defines the target parameters
notify-filter nf1; # Specifies which notify filter to apply
parameters {
message-processing-model v1;
security-model v1;
security-level none;
security-name john; # Matches the security name configured at the
} # [edit snmp v3 snmp-community community-index hierarchy level.
}
target-parameters tp2 {
notify-filter nf2;
parameters {
message-processing-model v1;
security-model v1;
security-level none;
security-name john;
}
}
target-parameters tp3 {
notify-filter nf3;
parameters {
message-processing-model v1;
security-model v1;
security-level none;
security-name john;
}
}
usm {
local-engine { # Defines authentication and encryption for SNMPv3 users
user john { # security-name john is defined here
authentication-md5 {
authentication-password authentication-password;
}
privacy-des {
privacy-password privacy-password;
}
}
user bob { # security-name bob is defined here
authentication-sha {
authentication-password authentication-password;
}
privacy-none;
}
user julia { # security-name julia is defined here
authentication-none;
privacy-none;
}
user lauren { # security-name lauren is defined here
authentication-sha {
authentication-password authentication-password;
}
privacy-aes128 {
privacy-password privacy-password;
}
}
user richard { # security-name richard is defined here
authentication-sha {
authentication-password authentication-password;
}
privacy-none;
}
}
}
vacm {
access {
group san-francisco { #Defines the access privileges for the group
default-context-prefix { # called san-francisco
security-model v1 {
security-level none {
notify-view ping-mib;
read-view interfaces;
write-view jnxAlarms;
}
}
}
}
}
security-to-group {
security-model v1 {
security-name john { # Assigns john to security group san-fancisco
group san-francisco;
}
security-name bob { # Assigns bob to security group new-york
group new-york;
}
security-name julia {# Assigns julia to security group chicago
group chicago;
}
security-name lauren {# Assigns lauren to security group paris
group paris;
}
security-name richard {# Assigns richard to security group geneva
group geneva;
}
}
}
}