networking, updated

SNMP

The Simple Network Management Protocol reads and changes settings on routers, switches, printers and servers, and sends alerts (traps). Versions 1 and 2c protect all of it with a clear-text password called a community string.

OSI layer
7 Application
Carried in
UDP
Ports
161/udp (agent), 162/udp (traps), 10161, 10162/udp (over DTLS)
Specs
RFC 1157, RFC 3416, RFC 3414
Wireshark filter
snmp
Encrypted
no

Packet structure

SNMP messages are ASN.1 in BER encoding, so there is no fixed layout. Wireshark shows a v2c request like this:

Simple Network Management Protocol
├─ version:   v2c (1)                   ← 0 = v1, 1 = v2c, 3 = v3
├─ community: public                    ← the password, in clear text
└─ data: get-request (0)
   ├─ request-id:   1928374651          ← matches the response
   ├─ error-status: noError (0)
   ├─ error-index:  0
   └─ variable-bindings
      ├─ 1.3.6.1.2.1.1.1.0 (sysDescr):  Value (Null)
      └─ 1.3.6.1.2.1.1.5.0 (sysName):   Value (Null)

In SNMPv3 the community is replaced by a security header (msgAuthoritativeEngineID, msgUserName, authentication and privacy parameters) and the PDU can be encrypted.

PDUPurpose
get-request / get-next-requestRead one value / the next one (walks the tree)
get-bulk-request (v2c, v3)Read many values at once
set-requestChange a value (configuration!)
get-responseAnswer to any of the above
trap (v1), snmpV2-trapAlert from device to manager, unacknowledged, port 162
inform-requestAcknowledged alert
report (v3)Errors and engine discovery

Values are addressed by OIDs in a tree defined by MIBs. Useful ones: 1.3.6.1.2.1.1 (system: description, contact, name, location), 1.3.6.1.2.1.2.2 (interfaces), 1.3.6.1.2.1.4.20 (IP addresses), 1.3.6.1.2.1.25.4.2 (running processes), 1.3.6.1.4.1 (vendor-specific).

How it works

sequenceDiagram
    participant M as Manager (NMS)
    participant A as Agent :161 (router, switch, printer)
    M->>A: get-request community=public sysName.0
    A->>M: get-response sysName.0 = "core-sw-01"
    M->>A: get-bulk-request ifTable
    A->>M: get-response (many values)
    A-->>M: trap to :162 (link down)

The manager polls agents on UDP 161; agents push traps to the manager on UDP 162. In v1 and v2c the agent accepts any request with the right community string (read-only or read-write). In v3 users authenticate with HMAC (SHA preferred over MD5) and can encrypt the PDU with AES.

In Wireshark

FilterShows
snmpAll SNMP
snmp.communityv1 and v2c requests (add the community as a column)
snmp.version == 3SNMPv3
snmp.set_request_elementSet requests: configuration changes
snmp.getBulkRequest_elementBulk reads (often a full walk)
snmp.trap_element || snmp.snmpV2_trap_elementTraps
snmp.error_status != 0Errors (wrong community shows no reply at all in v2c)
snmp.name == 1.3.6.1.2.1.1.1.0sysDescr queries (device fingerprinting)

Wireshark can decrypt SNMPv3 with the user’s keys (Preferences › Protocols › SNMP › Users Table).

What normal looks like: one or two monitoring servers poll devices on a fixed schedule; devices send traps to the same servers. SNMP from a workstation, many devices queried with the same community in a short time (a sweep with onesixtyone), set-request from anywhere but the NMS, or SNMP reaching the internet are suspicious.

Security notes

References

§ home
~/knubertus/home/
1,1 Top