SNMP
SNMP v2c and v3 community/user configuration, trap destinations, and MIB object navigation.
SNMPv2c — Community-Based
Switch(config)# access-list 99 permit 10.50.1.0 0.0.0.255
Switch(config)# snmp-server community <COMMUNITY-RO> RO 99
Switch(config)# snmp-server community <COMMUNITY-RW> RW 99
| SNMPv2c sends the community string in cleartext. Anyone on the wire can sniff it. Use SNMPv3 with auth+priv for anything beyond lab environments. At minimum, restrict v2c access with an ACL. |
SNMPv3 — User-Based Security
Switch(config)# snmp-server group MONITOR-GROUP v3 priv
Switch(config)# snmp-server user monitor-user MONITOR-GROUP v3 auth sha <AUTH-PASS> priv aes 128 <PRIV-PASS>
snmp-server user does not appear in show running-config for security reasons. Use show snmp user to verify it exists.
|
Switch(config)# snmp-server view IF-ONLY iso.3.6.1.2.1.2 included
Switch(config)# snmp-server group RESTRICTED-GROUP v3 priv read IF-ONLY
Switch(config)# snmp-server user restricted-user RESTRICTED-GROUP v3 auth sha <AUTH-PASS> priv aes 128 <PRIV-PASS>
Views are how you limit what OID subtrees a user can access. iso.3.6.1.2.1.2 is the interfaces MIB (IF-MIB).
Traps and Informs
Switch(config)# snmp-server host 10.50.1.100 version 2c <COMMUNITY-RO>
Switch(config)# snmp-server enable traps snmp linkdown linkup
Switch(config)# snmp-server enable traps config
Switch(config)# snmp-server enable traps envmon
Switch(config)# snmp-server host 10.50.1.100 informs version 2c <COMMUNITY-RO>
Switch(config)# snmp-server host 10.50.1.100 version 3 priv monitor-user
SNMP Source Interface
Switch(config)# snmp-server source-interface traps Loopback0
Querying from Linux
snmpwalk -v2c -c <COMMUNITY-RO> 10.50.1.10 IF-MIB::ifDescr
Expected output:
IF-MIB::ifDescr.1 = STRING: GigabitEthernet1/0/1
IF-MIB::ifDescr.2 = STRING: GigabitEthernet1/0/2
...
snmpget -v2c -c <COMMUNITY-RO> 10.50.1.10 SNMPv2-MIB::sysUpTime.0
snmpwalk -v3 -l authPriv \
-u monitor-user \
-a SHA -A <AUTH-PASS> \
-x AES -X <PRIV-PASS> \
10.50.1.10 IF-MIB::ifOperStatus
Install snmp and snmp-mibs-downloader on Debian/Ubuntu, or net-snmp-utils on RHEL/Arch, to get snmpwalk and MIB resolution.
|
Common OIDs
| OID / MIB Name | Description | Type |
|---|---|---|
|
Device description (model, firmware) |
STRING |
|
Uptime in hundredths of a second |
TimeTicks |
|
Interface names |
STRING |
|
Interface up/down (1=up, 2=down) |
INTEGER |
|
Bytes in/out per interface |
Counter32 |
|
64-bit byte counters (high capacity) |
Counter64 |
|
CPU utilization per core |
INTEGER |
|
Physical inventory (modules, fans, PSU) |
STRING |
Use ifHCInOctets/ifHCOutOctets (64-bit) instead of ifInOctets/ifOutOctets (32-bit) on high-speed interfaces. A 10Gbps link wraps a 32-bit counter in ~3.4 seconds.
Verification on the Device
Switch# show snmp
Switch# show snmp user
Switch# show snmp group
Switch# show snmp host
Switch# show snmp community
show snmp gives aggregate packet counts — useful for confirming that polls are arriving. If inBadCommunityNames is climbing, something is sending requests with the wrong community string.