LABS · SCENARIOS · CCNA V2.0

SNMP: the NOC asks, the router answers and warns

A scenario for CCNA v2.0 topic 5.4: the NOC's monitoring server reads R1's data with SNMP and R1 reports when a link goes down. Manager and agent, MIB and OIDs, get, getBulk, trap, and why SNMPv3 replaces the clear-text community.

Level: intermediate · 20 minutes

Interactive simulation

The animation needs JavaScript. The full lesson is written out below.

Download the capture and open it in Wireshark to keep exploring.

The parts of SNMP

PartWhat it isIn this lab
Manager (NMS)The system that asks and receives alertsLibreNMS, 192.168.20.60
AgentThe SNMP process on each deviceR1
MIBThe agent's database, shaped like a treeSNMPv2-MIB, IF-MIB and Cisco MIBs
OIDThe numeric identifier of each value1.3.6.1.2.1.1.3.0 = sysUpTime.0

SNMP is used to monitor (read states and counters, receive alerts) and, less often, to configure. Today it coexists with streaming telemetry and APIs (NETCONF and RESTCONF), but it is still the backbone of monitoring.

The messages

MessageSent byPurpose
get-requestManagerRead one or more values
get-next-requestManagerRead the next value in the tree (walk a table)
getBulkRequestManagerRead many rows in a single request (since v2)
set-requestManagerChange a value
responseAgentAnswer any of the above
trapAgentReport an event, without acknowledgment
informAgentReport an event, with acknowledgment

Ports: the agent listens on UDP 161; the manager receives traps and informs on UDP 162.

How it works: asking, reading a table, getting alerts and protecting it all

Five steps: a get, a getBulk, a trap, SNMPv3 discovery and an authPriv query.

  1. get-request: the manager asks for three values

    LibreNMS sends R1 a get-request over UDP 161 with three OIDs: sysName.0, sysUpTime.0 and ifOperStatus.4. The values go as NULL: the agent fills them in. R1 checks the community (snmp-server community N0c-Lectura RO) and that the source is in ACL SNMP-NMS, and answers with the same request-id: R1, up for 42 days, and interface 4 up. The whole message is BER-encoded: type, length and value, nested. Look at the inspector: the community can be read as is. Anyone who captures the traffic gets it. That is why SNMPv2c is limited to read-only with an ACL, or replaced by SNMPv3.

  2. getBulkRequest: a table in a single request

    To read the interface table, SNMPv1 needed one get-next per value. SNMPv2 added getBulkRequest: the manager asks for two columns (ifDescr and ifOperStatus) and max-repetitions 4, and R1 returns the next four rows of each in a single response: 8 variables. The number at the end of each OID is the ifIndex, the interface's index in the MIB (show snmp mib ifmib ifindex maps it to its name). This is how a monitoring system works: every few minutes it reads counters and states from all interfaces and draws graphs.

  3. snmpV2-trap: R1 reports without being asked

    Polling every few minutes is not enough to learn about a failure right away. With snmp-server enable traps snmp linkdown linkup and snmp-server host 192.168.20.60 version 2c N0c-Traps, R1 sends an snmpV2-trap as soon as Gi0/0/3 goes down. The first two variables are always sysUpTime.0 (when it happened) and snmpTrapOID.0 (what happened: linkDown). Then come the interface data: ifIndex, ifDescr, ifType and Cisco's own locIfReason. The trap goes to UDP 162 and gets no reply: if it is lost, nobody knows. To get an acknowledgment there are informs (informRequest).

  4. SNMPv3: first, discover the engineID

    SNMPv3 replaces the community with users that have authentication and encryption (the USM model). The keys are derived from the password and the agent's engineID, so the manager needs to know it first. It sends an empty, unsecured get-request with the reportable flag. R1 replies with a report: usmStatsUnknownEngineIDs, and its header carries its engineID (800000090300005E005301: Cisco + R1's MAC), how many times it has rebooted (engineBoots 7) and how many seconds it has been up (engineTime). That time protects against replayed messages: one more than 150 s off is dropped.

  5. authPriv: the same query, authenticated and encrypted

    Now the manager asks for sysUpTime.0 as user noc-snmp, at the authPriv level (msgFlags 0x07). Authentication is an HMAC-SHA-96 of the whole message with a key derived from the password and R1's engineID: if anyone changes a byte, R1 drops it. The PDU is encrypted with AES-128 in CFB mode; the initialization vector comes from engineBoots, engineTime and an 8-byte salt. The capture only shows random bytes: the inspector overlays what they carry, decrypted with the keys on this page. R1 answers the same way, authenticated and encrypted. The passwords never travel.

Versions

VersionSecurityUse today
SNMPv1Clear-text communityOld devices
SNMPv2cClear-text community; adds getBulk and informVery common, read-only and with an ACL
SNMPv3 noAuthNoPrivUser, no authentication or encryptionAlmost never
SNMPv3 authNoPrivAuthentication (HMAC-SHA)When the data need not be hidden
SNMPv3 authPrivAuthentication and encryption (AES)The recommended one

Configure on IOS XE

WhatCommand
Read-only community with an ACLsnmp-server community N0c-Lectura RO SNMP-NMS
SNMPv3 group with encryptionsnmp-server group NOC v3 priv
SNMPv3 usersnmp-server user noc-snmp NOC v3 auth sha … priv aes 128 …
Trap destinationsnmp-server host 192.168.20.60 version 2c N0c-Traps
Which traps to sendsnmp-server enable traps snmp linkdown linkup
Verifyshow snmp, show snmp user, show snmp group, show snmp engineID

SNMPv3 users are not stored in the running configuration: they do not show up in show running-config. You see them with show snmp user.

Frequently asked questions

What is the difference between a trap and an inform?

Both are alerts the agent sends. A trap gets no reply: if it is lost, nobody knows. An inform is acknowledged with a response, and the agent resends it if the acknowledgment does not arrive.

Why is SNMPv3 recommended?

Because in v1 and v2c the community travels in clear text and is enough to read (or, with RW, change) the MIB. SNMPv3 uses users with authentication (HMAC-SHA) and encryption (AES), and protects against replayed messages with engineBoots and engineTime.

What is an OID?

A numeric identifier in the MIB tree. For example, 1.3.6.1.2.1.1.3.0 is sysUpTime.0: iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysUpTime(3), instance 0.

Can SNMP change the configuration?

Yes, with set-request and an RW community or a user with a write view. It is uncommon and risky; for configuration NETCONF, RESTCONF or tools like Ansible are preferred.

Why does the manager first send an empty message in SNMPv3?

Because USM keys are computed with the agent's engineID, and the manager needs to know it. The report it gets back carries the engineID, engineBoots and engineTime.

What you take away

  • SNMP has a manager (NMS) that asks and agents on the devices that answer and send alerts.
  • Every value in the MIB has an OID; the manager reads with get, get-next and getBulk, and changes values with set.
  • The agent listens on UDP 161; traps and informs go to the manager on UDP 162.
  • A trap is not acknowledged; an inform is.
  • SNMPv1 and v2c use a clear-text community; SNMPv3 adds users, authentication and encryption.
  • To verify: show snmp, show snmp user, show snmp group and show snmp engineID.

NEXT STEP

From this lesson to the CCNA 2.0 Course

SNMP, syslog and network management (domain 5.0) are part of The House of Routing's CCNA 2.0 Course, with the Canadá Logística lab. We will let you know when it opens.

Upcoming protocol lessons

Sources

Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.