SNMP in Linux (Short Practical Guide)
SNMP is a lightweight protocol to monitor devices and servers. You can read metrics like CPU, memory, interfaces, disk usage, and uptime from one central tool.
1) When SNMP is useful
Use SNMP when you need:
- Basic infrastructure monitoring across mixed vendors.
- Simple polling from NMS tools (Zabbix, LibreNMS, PRTG, etc.).
- Device visibility where agent options are limited.
2) SNMP versions (quick choice)
- SNMPv1: old, avoid.
- SNMPv2c: common but uses plain-text community strings.
- SNMPv3: recommended (authentication and encryption).
For production, prefer SNMPv3.
3) Install SNMP tools and agent
# Debian/Ubuntu
sudo apt update
sudo apt install -y snmp snmpd
# RHEL/CentOS/Fedora
sudo dnf install -y net-snmp net-snmp-utils
sudo systemctl enable --now snmpd
4) Minimal secure SNMPv3 setup
Create a read-only SNMPv3 user:
sudo systemctl stop snmpd
sudo net-snmp-create-v3-user -ro -A "AuthPass123!" -X "PrivPass123!" -a SHA -x AES monitor
sudo systemctl enable --now snmpd
This creates a user monitor with auth+privacy (encrypted traffic).
5) Useful SNMP commands
Read system description:
snmpget -v3 -l authPriv -u monitor -a SHA -A "AuthPass123!" -x AES -X "PrivPass123!" localhost 1.3.6.1.2.1.1.1.0
Walk system tree:
snmpwalk -v3 -l authPriv -u monitor -a SHA -A "AuthPass123!" -x AES -X "PrivPass123!" localhost 1.3.6.1.2.1.1
Check interface counters:
snmpwalk -v3 -l authPriv -u monitor -a SHA -A "AuthPass123!" -x AES -X "PrivPass123!" localhost IF-MIB::ifTable
6) Good operational defaults
- Allow SNMP access only from monitoring server IPs.
- Use SNMPv3 read-only accounts for monitoring.
- Separate credentials per environment.
- Rotate credentials regularly.
- Keep firewall rules strict (UDP 161 only where needed).
7) Quick troubleshooting
- Confirm service state:
systemctl status snmpd --no-pager - Confirm listener:
ss -ulpn | grep 161 - Test locally first (
localhost) before remote checks. - If timeouts happen, verify firewall and routing.
- If auth fails, re-check username, auth/priv protocol, and passwords.
Quick checklist
- Install
snmpandsnmpdpackages. - Create SNMPv3 read-only user.
- Restrict access to trusted monitoring hosts.
- Validate with
snmpgetandsnmpwalk. - Add OIDs/MIBs to your monitoring platform.