在 Junos OS 中配置 SNMP
配置 SNMP
您可以在设备上运行的 Junos OS 软件中实施 SNMP。默认情况下,SNMP 未启用。要启用 SNMP,您必须在层次结构级别包含 [edit] SNMP 配置语句。
要配置 SNMP 的最低要求,请在层次结构级别上[edit snmp]使用 include community public 语句。
要配置完整的 SNMP 功能,请参阅 SNMP。
[edit snmp] 层级的配置语句
本主题显示层级的所有 [edit snmp] 配置语句及其在配置层级中的配置语句。配置 Junos OS 时,您当前的层级会显示在提示符前 user@host# 行的横幅中。
[edit] snmp { alarm-management { alarm-list-name list-name { alarm-id id { alarm-state state { description alarm-description; notification-id notification-id-of-alarm; resource-prefix alarm-resource-prefix; varbind-index varbind-index-in-alarm-varbind-list; varbind-subtree alarm-varbind-subtree; varbind-value alarm-varbind-value; } } } } client-list client-list-name { ip-addresses; } community community-name { authorization authorization; client-list-name client-list-name; clients { address <restrict>; } logical-system logical-system-name { routing-instance routing-instance-name; clients { address <restrict>; } } routing-instance routing-instance-name { clients { address <restrict>; } } view view-name; } contact contact; description description; engine-id { (local engine-id | use-default-ip-address | use-mac-address); } filter-duplicates; interface [ interface-names ]; location location; name name; nonvolatile { commit-delay seconds; } {rmon { alarm index { description description; falling-event-index index; falling-threshold integer; falling-threshold-interval seconds; interval seconds; request-type (get-next-request | get-request | walk-request); rising-event-index index; rising-threshold integer; sample-type type; startup-alarm alarm; syslog-subtag syslog-subtag; variable oid-variable; } event index { community community-name; description description; type type; } } traceoptions { file filename <files number> <size size> <world-readable | no-world-readable> <match regular-expression>; flag flag; memory-trace; no-remote-trace; no-default-memory-trace; } trap-group group-name { categories { category; } destination-port port-number; routing-instance instance; logical-system logical-system-name; targets { address; } version (all | v1 | v2); } trap-options { agent-address outgoing-interface; source-address address; enterprise-oid; logical-system logical-system-name { routing-instance routing-instance-name { source-address address; } } routing-instance routing-instance-name { source-address address; } } v3 { notify name { tag tag-name; type (trap | inform); } notify-filter profile-name { oid oid (include | exclude); } snmp-community community-index { community-name community-name; security-name security-name; tag tag-name; } target-address target-address-name { address address; address-mask address-mask; logical-system logical-system; port port-number; retry-count number; routing-instance instance; tag-list tag-list; target-parameters target-parameters-name; timeout seconds; } target-parameters target-parameters-name { notify-filter profile-name; parameters { message-processing-model (v1 | v2c | v3); security-level (authentication | none | privacy); security-model (usm | v1 | v2c); security-name security-name; } } usm { local-engine { user username { authentication-md5 { authentication-password authentication-password; } authentication-none; authentication-sha { authentication-password authentication-password; } privacy-3des { privacy-password privacy-password; } privacy-aes128 { privacy-password privacy-password; } privacy-des { privacy-password privacy-password; } privacy-none; } } } vacm { access { group group-name { (default-context-prefix | context-prefix context-prefiix){ security-model (any | usm | v1 | v2c) { security-level (authentication | none | privacy) { notify-view view-name; read-view view-name; write-view view-name; } } } } } security-to-group { security-model (usm | v1 | v2c) { security-name security-name { group group-name; } } } } } view view-name { oid object-identifier (include | exclude); } }
配置 SNMP 的基本设置
以下章节包含有关基本 SNMP 配置的信息,以及在运行 Junos OS 的设备上配置基本 SNMP 操作的一些示例:
配置 SNMPv1 和 SNMPv2 的基本设置
默认情况下,您无法在运行 Junos OS 的设备上启用 SNMP。要在运行 Junos OS 的设备上启用 SNMP,请在层次结构级别包含[edit snmp]该community public语句。
启用 SNMPv1 和 SNMPv2 Get 和 GetNext 操作
[edit]
snmp {
community public;
}
定义为公共的社区向任何客户端授予对所有 MIB 数据的访问权限。
要在设备上启用 SNMPv1 和 SNMPv2 Set 操作,必须在层次结构级别包含 [edit snmp] 以下语句:
启用 SNMPv1 和 SNMPv2 集操作
[edit snmp]
view all {
oid .1;
}
community private {
view all;
authorization read-write;
}
以下示例显示设备上 SNMPv1 和 SNMPv2 陷阱的基本最低配置:
配置 SNMPv1 和 SNMPv2 陷阱
[edit snmp]
trap-group jnpr {
targets {
192.168.69.179;
}
}
配置 SNMPv3 的基本设置
以下示例显示了在设备上启用 Get、 GetNext和 Set 操作的最低 SNMPv3 配置(请注意,该配置将身份验证设置为 md5 ,隐私 none设置为):
启用 SNMPv3 Get、GetNext 和 Set 操作
[edit snmp]
v3 {
usm {
local-engine {
user jnpruser {
authentication-md5 {
authentication-key "$9$guaDiQFnAuOQzevMWx7ikqP"; ## SECRET-DATA
}
privacy-none;
}
}
}
vacm {
security-to-group {
security-model usm {
security-name jnpruser {
group grpnm;
}
}
}
access {
group grpnm {
default-context-prefix {
security-model any {
security-level authentication {
read-view all;
write-view all;
}
}
}
}
}
}
}
view all {
oid .1;
}
以下示例显示设备上 SNMPv3 通知的基本配置(该配置具有身份验证和隐私设置 none):
配置 SNMPv3 通知
[edit snmp]
v3 {
usm {
remote-engine 00000063200133a2c0a845c3 {
user RU2_v3_sha_none {
authentication-none;
privacy-none;
}
}
}
vacm {
security-to-group {
security-model usm {
security-name RU2_v3_sha_none {
group g1_usm_auth;
}
}
}
access {
group g1_usm_auth {
default-context-prefix {
security-model usm {
security-level authentication {
read-view all;
write-view all;
notify-view all;
}
}
}
}
}
}
target-address TA2_v3_sha_none {
address 192.168.69.179;
tag-list tl1;
address-mask 255.255.252.0;
target-parameters TP2_v3_sha_none;
}
target-parameters TP2_v3_sha_none {
parameters {
message-processing-model v3;
security-model usm;
security-level none;
security-name RU2_v3_sha_none;
}
notify-filter nf1;
}
notify N1_all_tl1_informs {
type inform; # Replace inform with trap to convert informs to traps.
tag tl1;
}
notify-filter nf1 {
oid .1 include;
}
}
view all {
oid .1 include;
}
通过将层次结构级别trap的[edit snmp v3 notify N1_all_tl1_informs]语句值type设置为以下示例中所示,可以将 SNMPv3 通知转换为陷阱:
将通知转换为陷阱
user@host# set snmp v3 notify N1_all_tl1_informs type trap
也可以看看
配置 SNMP 详细信息
您可以使用 SNMP 存储基本管理详细信息,例如联系人姓名和设备位置。然后,当您排除故障或执行审计时,您的管理系统可以远程检索此信息。在 SNMP 术语中,这些对象是在 MIB-2 系统组中找到的 sysName、sysContact、sysDescription 和 sysLocation 对象(如 RFC 1213, 基于 TCP/IP 的互联网的网络管理管理信息库:MIB-II 中所定义)。您可以直接在 Junos OS 配置中为 SNMP 管理的每个系统设置初始值。
对于由 SNMP 管理的设备,请始终配置和更新名称、位置、联系人和描述信息。
要设置 SNMP 详细信息,请执行以下操作:
配置提交延迟计时器
当路由器或交换机首次收到 SNMP 非易失性 Set 请求时,将打开 Junos OS XML 协议会话,并阻止其他用户或应用程序更改候选配置(相当于命令行界面 [CLI] configure exclusive 命令)。如果在提交候选配置时,路由器收到新的 SNMP Set 请求,则 SNMP Set 请求将被拒绝并生成错误。如果路由器在 5 秒之前收到新的 SNMP Set 请求,则提交延迟计时器(从收到最后一个 SNMP 请求到请求提交之间的时间长度)将重置为 5 秒。
默认情况下,计时器设置为 5 秒。要配置 SNMP Set 回复和提交开始的计时器,请在层次结构级别包含该 commit-delay 语句 [edit snmp nonvolatile] :
[edit snmp nonvolatile] commit-delay seconds;
seconds 是从收到 SNMP 请求到请求提交以进行候选配置之间的时间长度。有关命令 configure exclusive 和锁定配置的更多信息,请参阅 Junos OS CLI 用户指南 。
在运行 Junos OS 的设备上配置 SNMP
默认情况下,在运行 Junos OS 的设备上禁用 SNMP。要在路由器或交换机上启用 SNMP,必须在层次结构级别包含 [edit snmp] SNMP 配置语句。
要配置 SNMP 的最低要求,请在层次结构级别上[edit snmp]使用 include community public 语句。
此处定义为的社区向 public 任何客户端授予对所有 MIB 数据的读取访问权限。
要配置完整的 SNMP 功能,请在 [edit snmp] 层次结构级别加入以下语句:
snmp { client-list client-list-name { ip-addresses; } community community-name { authorization authorization; client-list-name client-list-name; clients { address restrict; } routing-instance routing-instance-name { clients { addresses; } } logical-system logical-system-name { routing-instance routing-instance-name { clients { addresses; } } } view view-name; } contact contact; description description; engine-id { (local engine-id | use-mac-address | use-default-ip-address); } filter-duplicates; health-monitor { falling-threshold integer; interval seconds; rising-threshold integer; } interface [ interface-names ]; location location; name name; nonvolatile { commit-delay seconds; } rmon { alarm index { description text-description; falling-event-index index; falling-threshold integer; falling-threshold-interval seconds; interval seconds; request-type (get-next-request | get-request | walk-request); rising-event-index index; sample-type type; startup-alarm alarm; syslog-subtag syslog-subtag; variable oid-variable; } event index { community community-name; description text-description; type type; } } traceoptions { file filename <files number> <size size> <world-readable | no-world-readable> <match regular-expression>; flag flag; } trap-group group-name { categories { category; } destination-port port-number; routing-instance instance; targets { address; } version (all | v1 | v2); } trap-options { agent-address outgoing-interface; source-address address; } view view-name { oid object-identifier (include | exclude); } }
也可以看看
变更历史表
是否支持某项功能取决于您使用的平台和版本。使用 功能资源管理器 确定您的平台是否支持某个功能。
[edit snmp] CLI 中启用。