breakfixlearn.com

Real IOS labDomain 2 Network Security · topics 2.7

SNMPv3 Lab: authPriv, snmpwalk and snmpset

Configure SNMPv3 with SHA and AES on an IOS XE router, poll it from a Linux host with snmpwalk, change its hostname with snmpset, and read every SNMPv3 error.

Where to run this lab

  • Cisco Modeling Labs Catalyst 8000V or CSR 1000v routers plus an Ubuntu node. Recommended.
  • DevNet / dCloud IOS XE sandboxes, used from your own Linux machine.
  • Your own gear Any IOS XE router and a Linux VM on the same subnet.

Read the Secure Network Management: SNMPv3, NETCONF, RESTCONF, NTP & Syslog notes first. Topics: 2.7

show ip route | toc (12 sections)
  1. What you'll build
  2. Where to run this lab
  3. Topology
  4. Part 1: baseline
  5. Part 2: build it, verifying every step
  6. Part 3: read from the monitoring host
  7. Part 4: write with the read-write user
  8. Part 5: break it on purpose
  9. Harden it for production
  10. Check yourself
  11. Answer config
  12. Exam mapping

What you'll build

SNMPv3 on an IOS XE router, at the authPriv level (SHA authentication and AES encryption), locked to one monitoring host. Then you'll prove it from a Linux monitoring station with Net-SNMP: read the device description, hostname and interfaces, walk the whole MIB, and finally change the router's hostname over SNMP, which shows exactly why read-write SNMP needs to be locked down.

ItemDetail
PlatformAn IOS XE router and a Linux host with Net-SNMP (see where to run it, below)
Time45 to 60 minutes
LevelCCNP Security. You should be comfortable with the IOS CLI and a Linux shell
You'll practiceSNMP ACLs, views, groups and users; show snmp user; snmpwalk, snmpget and snmpset; reading SNMPv3 errors
Exam topic2.7 (core)
Before thisSecure Network Management notes, especially SNMPv3
PartWhat you doWhat it proves
1 BaselineCheck SNMP is offClean start
2 BuildACL, views, groups, usersEach object exists before the next depends on it
3 Readsnmpwalk from the monitoring hostAuthentication and encryption work end to end
4 Writesnmpset the hostname with the read-write userRead-write SNMP is real control over the device
5 BreakWrong keys, wrong level, wrong group, wrong sourceYou can name the fault from the error

The one thing to remember

SNMPv3 is four objects in a chain: ACL → view → group → user, at level authPriv. The fastest sanity check is show snmp user: it shows each user's protocols and, crucially, which group the user is in.

Think like the defender first

  • Who should be able to poll this router? One or two monitoring servers, not the whole network. That's the ACL.
  • What do they need to see? Usually interface counters and system information, not the whole MIB. That's the view. This lab exposes everything to keep it simple; the hardening section narrows it.
  • Does anything need to write? Most monitoring doesn't. Every read-write user is a way to change the device without logging in. Part 4 shows how much it can do.

Where to run this lab

EnvironmentHow to set it up
Cisco Modeling Labs (CML)A Catalyst 8000V (or CSR 1000v / IOSv) router and an Ubuntu node with the snmp package, on one subnet. Recommended
Cisco DevNet Sandbox / dCloudAn always-on or reservable IOS XE sandbox, polled from your own Linux machine over the sandbox VPN
Your own gearAny IOS XE router and a Linux VM with sudo apt install snmp (Debian / Ubuntu) or dnf install net-snmp-utils (Red Hat family)

Lab values only. The passphrases and addresses in this lab are training values shown in the screenshots. Never reuse them on real equipment.

Topology

  +-----------------------+                 +------------------------+
  |  Linux host (NMS)     |   10.0.0.0/24   |  Router R1 (IOS XE)    |
  |  10.0.0.5             | --------------> |  10.0.0.1              |
  |  snmpwalk / snmpset   |  UDP 161        |  SNMP agent            |
  +-----------------------+                 +------------------------+
ItemValue
RouterR1, 10.0.0.1, IOS XE 17.3
Monitoring host10.0.0.5, Net-SNMP tools
Read-only userROSNMPUSER: auth SHA 5678MmNnOoPp, priv AES-128 MnNnOo7890
Read-write userRWSNMPUSER: auth SHA 9876QqRrSsTt, priv AES-128 TtUuVv3456

Part 1: baseline

From the monitoring host, SSH to R1 and confirm SNMP isn't configured:

ssh john@10.0.0.1
show snmp user
show running-config | section snmp
R1 baseline: show snmp user returns SNMP agent not enabled and show running-config section snmp returns nothing
R1 baseline: show snmp user returns SNMP agent not enabled and show running-config section snmp returns nothing. Select the image to open it full size.

Read the output: %SNMP agent not enabled and an empty section snmp: no SNMP of any version is running. That's the safest default, and the state to return to on devices nobody monitors.

Part 2: build it, verifying every step

Step 1: ACL (only the monitoring host may speak SNMP)

configure terminal
 ip access-list standard SNMP-SERVERS
  remark SNMP Server #1
  permit 10.0.0.5
 end
show access-lists SNMP-SERVERS
show access-lists SNMP-SERVERS: standard IP access list with entry 10 permit 10.0.0.5
show access-lists SNMP-SERVERS: standard IP access list with entry 10 permit 10.0.0.5. Select the image to open it full size.

Read the output: one entry, 10 permit 10.0.0.5. Everything else hits the implicit deny. SNMP ACL denies are silent: a blocked host simply times out, with no error message to tell an attacker why.

Step 2: views (what part of the MIB is visible)

configure terminal
 snmp-server view SNMP-V3-RO-VIEW iso included
 snmp-server view SNMP-V3-RW-VIEW iso included
 do show run | include snmp-server view
show run include snmp-server view: SNMP-V3-RO-VIEW and SNMP-V3-RW-VIEW both include the iso subtree
show run include snmp-server view: SNMP-V3-RO-VIEW and SNMP-V3-RW-VIEW both include the iso subtree. Select the image to open it full size.

Read the output: both views include iso, the name for OID 1, the root of the tree. In other words, everything. That keeps the lab simple; production views should include only the subtrees the monitoring tool polls.

Step 3: groups (minimum level, views and ACL)

 snmp-server group SNMP-V3-RO v3 priv read SNMP-V3-RO-VIEW access SNMP-SERVERS
 snmp-server group SNMP-V3-RW v3 priv write SNMP-V3-RW-VIEW access SNMP-SERVERS
 do show snmp group
 do show snmp user
 do show run | include snmp-server group
Creating both groups with v3 priv; show snmp group and show snmp user still return SNMP agent not enabled, while show run include snmp-server group lists both groups
Creating both groups with v3 priv; show snmp group and show snmp user still return SNMP agent not enabled, while show run include snmp-server group lists both groups. Select the image to open it full size.

Read the output:

  • Both groups are in the running config: SNMPv3, minimum level priv (authPriv), the views, and the ACL.
  • show snmp group and show snmp user still say %SNMP agent not enabled. That's not a fault. On IOS XE, views and groups don't start the SNMP agent; the first user (or community) does. Until then, verify from the running config.
  • The read-only group has a read view; the read-write group has a write view. A group that must both read and write would list both (read SNMP-V3-RW-VIEW write SNMP-V3-RW-VIEW).

Step 4: users (identity and keys)

 snmp-server user ROSNMPUSER SNMP-V3-RO v3 auth sha 5678MmNnOoPp priv aes 128 MnNnOo7890 access SNMP-SERVERS
 snmp-server user RWSNMPUSER SNMP-V3-RW v3 auth sha 9876QqRrSsTt priv aes 128 TtUuVv3456 access SNMP-SERVERS
 end
show snmp user

Check the group name on each line before you press Enter: putting the read-write user in the read-only group is the classic mistake, and Part 5 shows what it looks like.

show snmp user: ROSNMPUSER and RWSNMPUSER, both with engine ID 8000000903000C1CA33C0000, active access-list SNMP-SERVERS, SHA authentication, AES128 privacy, and group names SNMP-V3-RO and SNMP-V3-RW
show snmp user: ROSNMPUSER and RWSNMPUSER, both with engine ID 8000000903000C1CA33C0000, active access-list SNMP-SERVERS, SHA authentication, AES128 privacy, and group names SNMP-V3-RO and SNMP-V3-RW. Select the image to open it full size.

Read the output, field by field:

  • Engine ID 8000000903000C1CA33C0000: the same for both users, because it belongs to the agent. The passphrases were hashed with it to make the real keys. If it ever changes, both users must be recreated.
  • storage-type: nonvolatile: the users survive a reload once the config is saved.
  • active access-list: SNMP-SERVERS: the host restriction is applied to the user too.
  • Authentication Protocol: SHA and Privacy Protocol: AES128: authPriv.
  • Group-name: SNMP-V3-RO for the read-only user and SNMP-V3-RW for the read-write user. This one field is what catches the most common SNMPv3 mistake.

Notice what's not here: the passphrases. SNMPv3 keys never appear in show running-config or show snmp user. You confirm a user by testing it, not by reading the key back.

Part 3: read from the monitoring host

Each snmpwalk names the version, the level, the user, and both protocols and passphrases:

FlagMeaning
-v3SNMP version 3
-a SHA / -AAuthentication protocol / passphrase
-x AES / -XPrivacy protocol / passphrase
-u ROSNMPUSERUsername
-l authPrivSecurity level (must meet the group's minimum; case doesn't matter)
10.0.0.1 <OID>Target and the OID to walk

sysDescr: what is this device?

snmpwalk -v3 -a SHA -A 5678MmNnOoPp -x AES -X MnNnOo7890 -u ROSNMPUSER -l authPriv 10.0.0.1 1.3.6.1.2.1.1.1
snmpwalk of 1.3.6.1.2.1.1.1 returns the sysDescr string: Cisco IOS Software Amsterdam, Virtual XE Software, Version 17.3.8a
snmpwalk of 1.3.6.1.2.1.1.1 returns the sysDescr string: Cisco IOS Software Amsterdam, Virtual XE Software, Version 17.3.8a. Select the image to open it full size.

Read the output: iso.3.6.1.2.1.1.1.0 = STRING: "Cisco IOS Software [Amsterdam], Virtual XE Software ... Version 17.3.8a". Two lessons:

  • Getting any answer means authentication and decryption worked. A wrong key would have failed (Part 5).
  • That string is gold for an attacker: platform and exact software version, ready to match against published vulnerabilities. That's why views matter and why SNMP must never be reachable from untrusted networks.

sysName and interfaces

snmpwalk -v3 -a SHA -A 5678MmNnOoPp -x AES -X MnNnOo7890 -u ROSNMPUSER -l authPriv 10.0.0.1 1.3.6.1.2.1.1.5
snmpwalk -v3 -a SHA -A 5678MmNnOoPp -x AES -X MnNnOo7890 -u ROSNMPUSER -l authPriv 10.0.0.1 1.3.6.1.2.1.31.1.1.1.1
snmpwalk of 1.3.6.1.2.1.1.5 returns sysName R1.cbt.local
snmpwalk of 1.3.6.1.2.1.1.5 returns sysName R1.cbt.local. Select the image to open it full size.
snmpwalk of the ifName column 1.3.6.1.2.1.31.1.1.1.1 returns Gi1 to Gi6, Vo0 and Nu0
snmpwalk of the ifName column 1.3.6.1.2.1.31.1.1.1.1 returns Gi1 to Gi6, Vo0 and Nu0. Select the image to open it full size.

Read the output:

  • sysName (.1.5.0) is the hostname plus domain.
  • ifName returns one row per interface. The last number of each OID is the ifIndex (1 to 8 here), the key SNMP uses for every per-interface counter. Vo0 is a virtual interface and Nu0 is Null0.
  • -l authpriv in lowercase works too: Net-SNMP doesn't care about case.

Useful OIDs to try next:

OIDObjectNotes
1.3.6.1.2.1.1.3sysUpTimeUptime in hundredths of a second
1.3.6.1.2.1.2.2.1.8ifOperStatus1 = up, 2 = down
1.3.6.1.2.1.2.2.1.7ifAdminStatus1 = up, 2 = down (writable)
1.3.6.1.2.1.2.2.1.10 / .16ifInOctets / ifOutOctetsTraffic counters

For a single value, snmpget is faster (scalars need the .0 instance): snmpget ... 10.0.0.1 1.3.6.1.2.1.1.5.0. For big tables, snmpbulkwalk uses GetBulk and is much quicker.

The whole MIB

snmpwalk -v3 -a SHA -A 5678MmNnOoPp -x AES -X MnNnOo7890 -u ROSNMPUSER -l authPriv 10.0.0.1 > snmp-fullwalk.txt
nano snmp-fullwalk.txt
The full walk saved to snmp-fullwalk.txt and opened in nano: 2440 lines starting with sysDescr, sysObjectID, sysUpTime, sysName and the interface table
The full walk saved to snmp-fullwalk.txt and opened in nano: 2440 lines starting with sysDescr, sysObjectID, sysUpTime, sysName and the interface table. Select the image to open it full size.

Read the output: 2440 lines from one command: system information, uptime (2:59:02), sysName, the interface table and much more. With no OID given, snmpwalk walks the standard MIB-2 tree; that's what iso included exposed. Imagine that walk run by someone else, and the case for scoped views makes itself.

Part 4: write with the read-write user

Read-write SNMP isn't monitoring; it's configuration. Change the router's sysName from the monitoring host:

snmpset -v3 -a SHA -A 9876QqRrSsTt -x AES -X TtUuVv3456 -u RWSNMPUSER -l authPriv 10.0.0.1 1.3.6.1.2.1.1.5.0 s "R1-SET-BY-SNMP"

s means the value is a string (i would be an integer). Then look at the router:

show snmp user
show run | include hostname
After the snmpset, the router prompt reads R1-SET-BY-SNMP; show snmp user still lists both users with RWSNMPUSER in group SNMP-V3-RW, and show run include hostname returns hostname R1-SET-BY-SNMP
After the snmpset, the router prompt reads R1-SET-BY-SNMP; show snmp user still lists both users with RWSNMPUSER in group SNMP-V3-RW, and show run include hostname returns hostname R1-SET-BY-SNMP. Select the image to open it full size.

Read the output:

  • The prompt itself changed to R1-SET-BY-SNMP#, and the running config now says hostname R1-SET-BY-SNMP. On IOS, sysName is tied to the hostname, so one SNMP packet renamed the device.
  • RWSNMPUSER is in SNMP-V3-RW, the group with the write view. That's why the set was allowed.

This is the attack in miniature. The same write access could set ifAdminStatus to 2 and shut an interface (snmpset ... 1.3.6.1.2.1.2.2.1.7.<ifIndex> i 2), or trigger a configuration copy off the device. Read-write SNMP is equivalent to configuration access. Give it only to tools that need it, from hosts that need it.

Put the hostname back when you're done: configure terminal, hostname R1.

Part 5: break it on purpose

Run each of these from the monitoring host, read the error, then fix it.

BreakCommand changeWhat you seeWhy
Wrong authentication passphrase-A WRONGPASS123Authentication failure (incorrect password, community or key)The HMAC doesn't verify
Wrong privacy passphrasecorrect -A, wrong -XTimeout, or a decryption errorThe agent can't decrypt the request
Level below the group's minimum-l authNoPriv (drop -x / -X)An error about an unsupported or insufficient security levelThe group requires authPriv
Source not in the ACLChange the ACL to permit another hostTimeout: No ResponseACL denies are silent
SNMPv2c attemptsnmpwalk -v2c -c public 10.0.0.1 1.3.6.1.2.1.1.5Timeout: No ResponseNo community exists: only v3 is configured
Read-write user in the read-only groupRecreate RWSNMPUSER with group SNMP-V3-RO, then snmpsetReads still work; the set fails with notWritable or noAccessThe group has no write view

Fixing the group mistake the way a troubleshooter would:

show snmp user
configure terminal
 snmp-server user RWSNMPUSER SNMP-V3-RW v3 auth sha 9876QqRrSsTt priv aes 128 TtUuVv3456 access SNMP-SERVERS
 end
show snmp user

Group-name changes from SNMP-V3-RO to SNMP-V3-RW, and the set works again.

Two timeouts, different causes. "Timeout: No Response" can mean a wrong privacy key, a blocked source, or no matching user. Check the cheap things first: is the host in the ACL (show access-lists SNMP-SERVERS hit counts), and is the privacy passphrase right?

Harden it for production

Lab shortcutProduction fix
iso included viewsViews limited to what's polled, e.g. snmp-server view MON-VIEW system included and interfaces included
A read-write userNo RW unless a tool needs it; separate RW user, separate ACL
AES-128 and SHA-1The strongest your release supports (snmp-server user ?): AES-256 and SHA-2 where available
Passphrases typed on the command lineLong, unique passphrases per role, stored in the NMS's credential vault
SNMP reachable from the user networkOut-of-band management network; UDP 161 filtered everywhere else
No notificationsSNMPv3 informs to the NMS: snmp-server host <nms> informs version 3 priv <user>

Check yourself

1. Why do show snmp group and show snmp user fail after the groups exist?

On IOS XE the SNMP agent starts only when the first user or community exists. Views and groups alone don't start it, so the operational show snmp commands report %SNMP agent not enabled until Step 4.

2. A walk with -l authNoPriv fails against these groups. Why?

The groups were created with priv, so authPriv is the minimum. A request at a lower level is refused.

3. Reads work for RWSNMPUSER but every snmpset fails. First command?

show snmp user. Check the Group-name: a read-write user created in the read-only group has no write view.

4. Why must users be recreated if the engine ID changes?

The passphrases are localized: hashed with the engine ID to produce the actual keys. A new engine ID means the stored keys no longer match.

5. Why is sysDescr sensitive?

It reveals the platform and exact software version, which an attacker can match against known vulnerabilities. Scope views and restrict who can poll.

Answer config

Show the final SNMPv3 config for R1
ip access-list standard SNMP-SERVERS
 remark SNMP Server #1
 permit 10.0.0.5
!
snmp-server view SNMP-V3-RO-VIEW iso included
snmp-server view SNMP-V3-RW-VIEW iso included
snmp-server group SNMP-V3-RO v3 priv read SNMP-V3-RO-VIEW access SNMP-SERVERS
snmp-server group SNMP-V3-RW v3 priv write SNMP-V3-RW-VIEW access SNMP-SERVERS
snmp-server user ROSNMPUSER SNMP-V3-RO v3 auth sha 5678MmNnOoPp priv aes 128 MnNnOo7890 access SNMP-SERVERS
snmp-server user RWSNMPUSER SNMP-V3-RW v3 auth sha 9876QqRrSsTt priv aes 128 TtUuVv3456 access SNMP-SERVERS

Lab values only. SNMPv3 users don't appear in show running-config; they live in the agent's user table.

Exam mapping

You practicedExam angleSCOR v2.0
ACL → view → group → userSNMPv3 object model (USM, VACM)2.7
v3 priv, SHA + AESSecurity levels; authPriv2.7
show snmp userEngine ID, protocols, group membership2.7
snmpwalk, snmpget, snmpsetPorts, operations, OIDs2.7
Read-write hostname changeWhy RW SNMP is configuration access2.7

Drill it with the flashcards and the mock exam.