Set up SNMPv3 authPriv monitoring and remote syslog on a router
Cisco IOSWorking
Tasks
- Allow SNMP queries only from 10.0.0.50.
- Create a read-only SNMPv3 group at authPriv with a view of the standard MIB-2 tree and Cisco's enterprise tree.
- Create user nmsuser in that group with SHA and AES-128.
- Send SNMPv3 traps for link up, link down and configuration changes to NMS1.
- Send syslog at informational and above to LOG1, keep a local buffer, and limit the console to warnings.
- Verify the user, a successful poll, a refused poll from another host and a log message arriving on LOG1.
Solution
1Access list and viewR1
R1 on Cisco IOS ip access-list standard SNMP-MGRS permit 10.0.0.50 ! snmp-server view NMS-VIEW 1.3.6.1.2.1 included snmp-server view NMS-VIEW 1.3.6.1.4.1.9 included1.3.6.1.2.1 is MIB-2 (system, interfaces, IP and more). 1.3.6.1.4.1.9 is Cisco's enterprise tree.
2Group and userR1
R1 on Cisco IOS snmp-server group NMS-RO v3 priv read NMS-VIEW access SNMP-MGRS snmp-server user nmsuser NMS-RO v3 auth sha Auth-Pass-2026 priv aes 128 Priv-Pass-2026privon the group means authPriv. No write view is given, so the group is read-only. The user line does not appear in the running config; check it withshow snmp user.3Traps, source and ifIndex persistenceR1
R1 on Cisco IOS snmp-server trap-source Loopback0 snmp-server ifindex persist snmp-server enable traps snmp linkdown linkup snmp-server enable traps config snmp-server host 10.0.0.50 version 3 priv nmsuserTraps need no acknowledgment, so the manager's engine ID is not required. Informs over v3 would need it.
4SyslogR1
R1 on Cisco IOS service timestamps log datetime msec show-timezone logging buffered 64000 informational logging console warnings logging source-interface Loopback0 logging host 10.0.0.60 logging trap informational
Verify
R1# show snmp user
User name: nmsuser
Engine ID: 80000009030000A3D14F2B00
storage-type: nonvolatile active
Authentication Protocol: SHA
Privacy Protocol: AES128
Group-name: NMS-ROThe user exists with SHA and AES128 in group NMS-RO. The engine ID is Cisco's prefix 800000090300 plus a MAC address of R1.
NMS1# snmpget -v3 -l authPriv -u nmsuser -a SHA -A 'Auth-Pass-2026' -x AES -X 'Priv-Pass-2026' 10.255.0.1 SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: R1An authenticated, encrypted poll from the permitted manager works.
OTHER1# snmpget -v3 -l authPriv -u nmsuser -a SHA -A 'Auth-Pass-2026' -x AES -X 'Priv-Pass-2026' 10.255.0.1 SNMPv2-MIB::sysName.0
Timeout: No Response from 10.255.0.1.The same credentials from another host, 10.0.0.77, get no answer because the group's access list refuses it.
R1# show logging | include Trap logging|Logging to
Trap logging: level informational, 58 message lines logged
Logging to 10.0.0.60 (udp port 514, audit disabled,Logs go to 10.0.0.60 over UDP 514 at informational and above.
LOG1# tail -n 1 /var/log/network/r1.log
Nov 10 10:02:41 10.255.0.1 58: Nov 10 10:02:40.512 UTC: %SYS-5-CONFIG_I: Configured from console by admin on vty0 (10.0.0.50)After a config change on R1, the message arrives from the loopback address with R1's own UTC
millisecond timestamp. %SYS-5-CONFIG_I is severity 5, notifications. The file path depends on how
the syslog server is set up.
Mistakes people make
- Looking for the SNMPv3 user in the running config and assuming it was not saved.
- Using a group level of
authand believing the traffic is encrypted. Onlyprivencrypts. - Changing
snmp-server engineID locallater. Every user's keys become invalid and must be re-created. - Passphrases shorter than 8 characters. net-snmp refuses them.
- Forgetting
logging source-interface: messages arrive from whichever interface faces the server, and the syslog server files them under the wrong host. - Sending debugging level to the syslog server and flooding it.
On other platforms
The same on Junos.
set snmp v3 usm local-engine user nmsuser authentication-sha authentication-password "Auth-Pass-2026"
set snmp v3 usm local-engine user nmsuser privacy-aes128 privacy-password "Priv-Pass-2026"
set snmp v3 vacm security-to-group security-model usm security-name nmsuser group NMS-RO
set snmp v3 vacm access group NMS-RO default-context-prefix security-model usm security-level privacy read-view NMS-VIEW
set snmp view NMS-VIEW oid 1.3.6.1.2.1 include
set system syslog host 10.0.0.60 any info
set system syslog source-address 10.255.0.1Say it in the interview
"SNMPv3 at authPriv: a view for what can be read, a group that sets the security level and the access list, and a user with SHA and AES. I remember the user never shows in the config and is tied to the engine ID. For syslog: millisecond UTC timestamps, a loopback source, informational to the server and warnings on the console. I test a poll from the manager, a refused poll from elsewhere, and a real message landing on the server."