Chapter 4: SNMP Trap Simulation & Syslog Alerts (snmp2, snmp3 & syslog)
Simulate SNMPv2c and encrypted SNMPv3 authPriv traps plus Syslog alerts to verify Zabbix, PRTG, LibreNMS, or Splunk alerting without pulling live cables.
Verify your NMS pages the on-call engineer when building uplink Gi1/0/24 goes down—without unplugging the fiber feeding Building 2.
What You'll Pull Off Here
- Emit RFC 5424
syslogalerts on UDP 514 withfacility,severity,hostname,app, andmsg. - Simulate MIB-free
snmp2 trapand encryptedsnmp3 trap(sha256+aes) packets on UDP 162. - Attach numeric OID
varbindpairs (oidval,string,int,timeticks) cleanly.
Lab 4: Simulate a Critical Gi1/0/24 Uplink SNMPv3 Trap & Syslog Alert
Escalate the syslog alert from severity 4 to critical severity 2 mentioning "Gi1/0/24", and update the snmp3 trap interface varbind from "Gi1/0/1" to "Gi1/0/24".
- 1.On the
syslogline, changeseverity 4toseverity 2and mentionGi1/0/24insidemsg "...". - 2.On the
snmp3 trapline, changestring "Gi1/0/1"tostring "Gi1/0/24". - 3.Click Check Exercise to verify both alerts compile cleanly.
1. Simulating SNMPv2c & Encrypted SNMPv3 Traps Without MIB Files
Testing SNMPv3 traps with CLI tools like snmptrap often turns into a fight over missing vendor MIB paths, engine IDs, and key-localization flags.
FrameAssembly builds standard UDP 162 trap packets and runs full SHA-256 HMAC authentication + AES-128 encryption directly from numeric OIDs. For a linkDown trap, pair 1.3.6.1.6.3.1.1.4.1.0 (snmpTrapOID.0) with oidval 1.3.6.1.6.3.1.1.5.3, then add interface varbinds like ifDescr.
- String varbinds use the full word
string "..."(neverstr "..."). snmp3engineidexpects an even-length hex string such as"80001f888011223344".trap,inform, andreportdefault to UDP162;get,getnext,getbulk, andsetdefault to UDP161.
Word-by-Word Syntax BreakdownAnatomy of an SNMP trap carrying two numeric varbinds:
access_sw -> nms_srv snmp2 trap community "noc-alerts" sysuptime 125000 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.3 varbind 1.3.6.1.2.1.2.2.1.2.24 string "Gi1/0/24"snmp2 trapPDU TypeSNMPv2c Trapv2-PDU routed automatically to UDP 162community "noc-alerts"AuthCommunity string (or user + auth + priv on snmp3)varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.3Trap OIDSets snmpTrapOID.0 to standard linkDownvarbind 1.3.6.1.2.1.2.2.1.2.24 string "Gi1/0/24"Payload VarbindSets ifDescr.24 to "Gi1/0/24"Quick Formatting Reference (2 rules)
| Item | Valid .frasm | Avoid |
|---|---|---|
| Varbind string keyword | varbind 1.3.6.1.2.1.1.5.0 string "sw-floor2" | varbind 1.3.6.1.2.1.1.5.0 str "sw-floor2" |
| Setting Trap OID | snmp2 trap varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.3 | snmp2 trap trapoid 1.3.6.1.6.3.1.1.5.3 |
syslog || snmp