SNMP — Polling Devices for Stats
20 min In ProgressLearning Objectives
- Explain what SNMP is used for
- Know the key difference between SNMPv2c and SNMPv3
- Build a simulated OID lookup + security checker
SNMPv2c vs SNMPv3
SNMP lets a central server (SolarWinds, Zabbix, PRTG) poll devices for stats like CPU and interface traffic. SNMPv2c is simple but sends its 'community string' password in plain text -- anyone sniffing the wire can read it. SNMPv3 adds real authentication and encryption and is what you should use in production.
! SNMPv2c -- plaintext community string, avoid in production
snmp-server community MyReadOnlyString RO
snmp-server location server-room-1
! SNMPv3 -- authenticated + encrypted
snmp-server group ADMINGROUP v3 priv
snmp-server user netadmin ADMINGROUP v3 auth sha MyAuthPass123 priv aes 128 MyPrivPass123
Practice — Simulated OID Poll
SNMP works by polling OIDs (object identifiers) -- think of them as addresses for specific stats. Here's a tiny simulated poller.
OID_TABLE = {
"1.3.6.1.2.1.1.5.0": "core-sw1", # sysName
"1.3.6.1.2.1.1.3.0": "19 days, 3:41", # sysUptime
}
def snmp_get(oid):
return OID_TABLE.get(oid, "No Such Object")
print(snmp_get("1.3.6.1.2.1.1.5.0"))
📝 Exercise: Build an SNMP Security Auditor
Write a function audit_snmp_config(config) that takes a dict describing a device's SNMP setup and returns a list of warning strings. Flag it if version is 'v2c' ('Plaintext community string -- upgrade to SNMPv3'), if version is 'v3' but encryption is False ('SNMPv3 without privacy is no better than v2c'), and if community is 'public' or 'private' ('Default community string in use -- change it immediately').