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)
- 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.
| PDU | Purpose |
|---|---|
get-request / get-next-request | Read one value / the next one (walks the tree) |
get-bulk-request (v2c, v3) | Read many values at once |
set-request | Change a value (configuration!) |
get-response | Answer to any of the above |
trap (v1), snmpV2-trap | Alert from device to manager, unacknowledged, port 162 |
inform-request | Acknowledged 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
| Filter | Shows |
|---|---|
snmp | All SNMP |
snmp.community | v1 and v2c requests (add the community as a column) |
snmp.version == 3 | SNMPv3 |
snmp.set_request_element | Set requests: configuration changes |
snmp.getBulkRequest_element | Bulk reads (often a full walk) |
snmp.trap_element || snmp.snmpV2_trap_element | Traps |
snmp.error_status != 0 | Errors (wrong community shows no reply at all in v2c) |
snmp.name == 1.3.6.1.2.1.1.1.0 | sysDescr 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
- Default and weak community strings:
public(read) andprivate(read-write) are still common. Read access leaks network topology, routing tables, ARP tables, user names and running software; write access can change device configuration or download it (CiscoCISCO-CONFIG-COPY-MIBvia TFTP). - Clear text: v1 and v2c send the community in every packet, so one capture is enough to steal it.
- Brute force: dictionary attacks against community strings are fast; the agent usually answers only when the string is right.
- Amplification DDoS: a small
get-bulk-requestwith a spoofed source returns a large reply. Never expose UDP 161 to the internet. - SNMPv3 weaknesses: MD5/DES modes are weak, and the engine ID and user name are visible; captured authenticated requests allow offline password cracking.
- Fix: use SNMPv3 with authPriv (SHA-2, AES), restrict agents to the management network with ACLs, disable write access where not needed.
Versions and related
- SNMPv1 (RFC 1157) and SNMPv2c (RFC 3416 with community strings) are still the most common.
- SNMPv3 (RFC 3411 to 3418) adds users, authentication and encryption (User-based Security Model, RFC 3414).
- NETCONF / RESTCONF and streaming telemetry (gNMI) are replacing SNMP for configuration on modern equipment.
- Runs over UDP; configuration backups often move over TFTP. Device logs go out via Syslog.