Cloud Explainers

How SNMP Network Monitoring Works

Networking9 min videoPublished Nov 16, 2026

How SNMP network monitoring works, on real machines: a manager asks an agent for one value on UDP port 161, every value has an address (an OID) that MIB files name, a link's speed is two counter readings subtracted, and traps on port 162 report changes the moment they happen. On Ubuntu 24.04 with Net-SNMP 5.9.4 we fix a stock agent that answers no one, read a router's internet line, see a wrong community get silence, and compare SNMP version 2c and version 3 on the wire.

No login, still an answer

You want to see how busy your router is, without logging into it. At a craft brewery, the router sits in a back room, and Ana's office PC prints, every five seconds, how fast data comes in from the internet. About 28 megabits a second while a guest streams a video. Nobody logged in. The router just answered, which is more than most printers do. So how does a PC ask a router about itself? And by the end, the router calls Ana first.

Ana at the office PC
wan-rate 421:47:17  internet in:  27.6 Mbit/s
21:47:22  internet in:  27.0 Mbit/s
21:47:28  internet in:  13.7 Mbit/s
21:47:33  internet in:  27.7 Mbit/s

Manager, agent, one question

It works like the electricity meter at your house. The meter never tells anyone your usage. It just counts up. The meter reader writes the number down on each visit, and your bill is the difference. That's most of network monitoring: devices keep counters, and a manager comes by to read them, again and again. That's called polling.

An electricity meter vs a router's counters: comparison table of Your house vs SNMP, Counts, Reads it, Usage, Name

The protocol is SNMP, the Simple Network Management Protocol. It has two roles. The manager, Ana's PC, asks. An agent, a small program on each device, answers. The question is one UDP packet to port 161: give me this value. The answer comes straight back. UDP means no connection to set up first: one packet out, one back, which is why one manager can check on thousands of devices. And when something breaks, the agent can speak first: a trap, sent to the manager's port 162.

SNMP: the manager asks, every agent answers: diagram of Manager, Router, Brewhouse, GET sysName, "router", "brewhouse", trap: linkDown

A stock agent answers no one

Ana starts from a plain Ubuntu router with Ubuntu's own agent, snmpd. snmpget asks for one value, the router's name, by its number. Dash v picks the version, 2c, and dash c the community, a shared word, here Ubuntu's default, public. Timeout. No response. On the router, ss lists the ports programs are listening on. On port 161, only 127.0.0.1: the router's address for talking to itself.

Ana: office PC and router
snmpget -v2c -c public router 1.3.6.1.2.1.1.5.0Timeout: No Response from router.
Ana: office PC and router
sudo ss -ulpn | grep :161UNCONN 0 0 127.0.0.1:161 0.0.0.0:* users:(("snmpd",pid=135,fd=6))
UNCONN 0 0 [::1]:161 [::]:* users:(("snmpd",pid=135,fd=7))

Ubuntu ships it that way on purpose: nothing answers the network until you say so. One line in snmpd.conf, the agent address, becomes U D P 161 on every address.

One line: listen on the network: code change of /etc/snmp/snmpd.conf, agentaddress udp:161 (every address, UDP 161)

After a restart, it listens on every address, and the same question gets an answer: a long number, then the router's name.

Ana: office PC and router
sudo systemctl restart snmpd
Ana: office PC and router
sudo ss -ulpn | grep :161UNCONN 0 0 0.0.0.0:161 0.0.0.0:* users:(("snmpd",pid=187,fd=6))
Ana: office PC and router
snmpget -v2c -c public router 1.3.6.1.2.1.1.5.0iso.3.6.1.2.1.1.5.0 = STRING: "router"

The long number is an address

That long number is an O I D, an object identifier: an address in one big tree that every SNMP device shares. 1.3.6.1 is the internet branch. 2.1 is the standard management values. The next 1 is the system group, 5 is its name, and the 0 at the end means the one and only copy.

One value's address: an OID: diagram of 1.3.6.1.2.1.1.5.0, 1.3.6.1 = the internet, 2.1 = standard values, 1 = system, 5 = sysName, 0 = the one copy, Same address on a router, a server or a printer

A MIB, a management information base, is the dictionary that names those numbers. snmptranslate looks one up: sysName. Ubuntu ships the tools with names turned off, so she turns on three standard MIBs in the tools' settings file, snmp.conf, with no D. Now the router answers in words: its name, and how long it's been running.

Ana at the office PC
snmptranslate -m SNMPv2-MIB 1.3.6.1.2.1.1.5.0SNMPv2-MIB::sysName.0
Ana at the office PC
echo 'mibs +SNMPv2-MIB:IF-MIB:HOST-RESOURCES-MIB' | sudo tee -a /etc/snmp/snmp.confmibs +SNMPv2-MIB:IF-MIB:HOST-RESOURCES-MIB
Ana at the office PC
snmpget -v2c -c public router sysName.0 hrSystemUptime.0SNMPv2-MIB::sysName.0 = STRING: router
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (86265) 0:14:22.65

Who may read what

What about the router's network interfaces? snmpwalk asks for every value under one name, one after another. No such object available on this agent. The router's settings say why. A view is a rule for which branches of the tree a community may read, and public gets only systemonly: the name, the uptime, and little else.

Ana: office PC and router
snmpwalk -v2c -c public router IF-MIB::ifDescrIF-MIB::ifDescr = No Such Object available on this agent at this OID
Ana: office PC and router
sudo grep -E '^(view|rocommunity)' /etc/snmp/snmpd.confview   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
rocommunity  public default -V systemonly
rocommunity6 public default -V systemonly

So Ana replaces public with a community only the office knows, brew-mon, accepted only from the office PC's address. Two more lines tell the agent to send its alerts, the traps, to the office. After a restart, the walk works: twelve interfaces. Loopback, nine tunnel placeholders Linux makes by itself, and the two that matter: lan, the taproom side, and wan, the internet line, number twelve.

Ana: office PC and router
sudo grep -E '^(rocommunity|trap2sink|authtrapenable)' /etc/snmp/snmpd.confrocommunity  brew-mon 192.168.71.20
trap2sink       192.168.71.20 brew-trap
authtrapenable  1
Ana: office PC and router
sudo systemctl restart snmpd
Ana: office PC and router
snmpwalk -v2c -c brew-mon router IF-MIB::ifDescrIF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: tunl0
IF-MIB::ifDescr.3 = STRING: gre0
IF-MIB::ifDescr.4 = STRING: gretap0
IF-MIB::ifDescr.5 = STRING: erspan0
IF-MIB::ifDescr.6 = STRING: ip_vti0
IF-MIB::ifDescr.7 = STRING: ip6_vti0
IF-MIB::ifDescr.8 = STRING: sit0
IF-MIB::ifDescr.9 = STRING: ip6tnl0
IF-MIB::ifDescr.10 = STRING: ip6gre0
IF-MIB::ifDescr.11 = STRING: lan
IF-MIB::ifDescr.12 = STRING: wan

Speed is two readings

How fast is that line right now? SNMP has no speedometer. RFC 2863, the internet standard for interface values, defines a counter instead: ifHCInOctets, the total number of bytes received on the interface. A 64-bit counter: it only goes up.

Speed is two readings: browser screenshot of the standard's definition, bytes in, only counts up

So Ana reads the wan counter, ifHCInOctets dot twelve, for interface twelve, waits ten seconds, and reads it again. forty-two million bytes, then sixty-nine million. Guess first: how fast is the line? About twenty-two megabits a second. The difference is twenty-seven million bytes in ten seconds, times eight for bits.

Ana at the office PC
snmpget -v2c -c brew-mon router IF-MIB::ifHCInOctets.12; sleep 10; snmpget -v2c -c brew-mon router IF-MIB::ifHCInOctets.12IF-MIB::ifHCInOctets.12 = Counter64: 41761049
IF-MIB::ifHCInOctets.12 = Counter64: 68696555

That's the whole trick behind every traffic graph: read, wait, read again, subtract, the meter reader's job. Ana's little script does it every five seconds, and so do monitoring tools like Zabbix and LibreNMS, for hundreds of devices.

The manager subtracts: ≈ 21.5 Mbit/s: diagram of Office PC, Router, GET ifHCInOctets.12, 41,761,049, 68,696,555

Why the 64-bit counter? The older one, ifInOctets, has 32 bits, so it starts again from zero after about 4.3 billion bytes. At this brewery's 22 megabits a second, that happens every 27 minutes. A manager that reads it less often than that can't tell one lap from two. The 64-bit one won't wrap for thousands of years.

A 32-bit byte counter wraps around: figure of 27 min until ifInOctets starts again from 0, at 21.5 Mbit/s, source: RFC 2863 (ifInOctets: Counter32; ifHCInOctets: Counter64) and our measured rate

The wrong community

What happens when someone tries the wrong community? From the office, Ana tries the old one, public. Guess first: what comes back? Nothing at all. snmpget waits a second, tries five more times, and gives up after six seconds.

Ana at the office PC
snmpget -v2c -c public router sysName.0Timeout: No Response from router.

The agent never says no, so a stranger can't even tell whether anyone is listening. But it does tell Ana. Her trap log has a new entry from the router: authentication failure.

Ana at the office PC
journalctl -u snmptrapd -o cat -n 421:46:38  trap from UDP: [192.168.71.1]:36134->[192.168.71.20]:162
    SNMPv2-MIB::sysUpTime.0 = Timeticks: (1620) 0:00:16.20
    SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-MIB::authenticationFailure
    SNMPv2-MIB::snmpTrapEnterprise.0 = OID: SNMPv2-SMI::enterprises.8072.3.2.10

Who else can read it

So the community is like a password. Who else can read it? On the router, tcpdump, a packet capture tool, prints the next packet that arrives on port 161. Ana asks for the name again, and there it is: the community, brew-mon, in plain text, for anyone who can see the traffic.

Ana: office PC and router
sudo tcpdump -n -v -c 1 -i lan udp port 161tcpdump: listening on lan, link-type EN10MB (Ethernet), snapshot length 262144 bytes
21:46:43.228804 IP (tos 0x0, ttl 64, id 31780, offset 0, flags [DF], proto UDP (17), length 73)
    192.168.71.20.46498 > 192.168.71.1.161:  { SNMPv2c C="brew-mon" { GetRequest(28) R=2147360876  .1.3.6.1.2.1.1.5.0 } }
1 packet captured
1 packet received by filter
0 packets dropped by kernel
Ana: office PC and router
snmpget -v2c -c brew-mon router sysName.0SNMPv2-MIB::sysName.0 = STRING: router

SNMP version 3 fixes that with users. Ana makes one with two passwords: one proves who's asking, checked with SHA-256, and one scrambles the contents, with AES encryption. The same question still gets the router's name. On the wire, the packet names the user, ana, and the rest is scrambled.

Ana: office PC and router
sudo systemctl stop snmpd && sudo net-snmp-create-v3-user -ro -a SHA-256 -A Hop-Kettle-42 -x AES -X Mash-Tun-77 ana && sudo systemctl start snmpdadding the following line to /var/lib/snmp/snmpd.conf:
   createUser ana SHA-256 "Hop-Kettle-42" AES "Mash-Tun-77"
adding the following line to /etc/snmp/snmpd.conf:
   rouser ana
Ana: office PC and router
snmpget -v3 -l authPriv -u ana -a SHA-256 -A Hop-Kettle-42 -x AES -X Mash-Tun-77 router sysName.0SNMPv2-MIB::sysName.0 = STRING: router
Ana: office PC and router
sudo tcpdump -n -v -c 3 -i lan udp port 161tcpdump: listening on lan, link-type EN10MB (Ethernet), snapshot length 262144 bytes
21:46:47.929996 IP (tos 0x0, ttl 64, id 36183, offset 0, flags [DF], proto UDP (17), length 92)
    192.168.71.20.50731 > 192.168.71.1.161:  { SNMPv3 { F=r } { USM B=0 T=0 U="" } { ScopedPDU E= C="" { GetRequest(14) R=606196376  } } }
21:46:47.992199 IP (tos 0x0, ttl 64, id 50656, offset 0, flags [DF], proto UDP (17), length 143)
    192.168.71.1.161 > 192.168.71.20.50731:  { SNMPv3 { F= } { USM B=5 T=5 U="" } { ScopedPDU E=_80_00_1f_88_80_e3_e6_21_17_9a_79_fb_6a_00_00_00_00 C="" { Report(31) R=606196376  .1.3.6.1.6.3.15.1.1.4.0=1 } } }
21:46:47.992993 IP (tos 0x0, ttl 64, id 36191, offset 0, flags [DF], proto UDP (17), length 178)
    192.168.71.20.50731 > 192.168.71.1.161:  { SNMPv3 { F=apr } { USM B=5 T=5 U="ana" } { ScopedPDU [!scoped PDU]a3_64_59_3e_51_3e_34_0c_43_cd_3f_06_eb_d0_03_67_82_76_2a_02_f9_c2_e3_18_2d_52_fc_e5_ce_e2_aa_29_59_3f_f7_03_d2_01_d1_2f_2a_5f_61_b9_2e_65_dc_7f_f4_d0_a4_e2_e6} }
3 packets captured
3 packets received by filter
0 packets dropped by kernel

The router speaks first

Polling every five seconds is fine for a graph. But Ana also told the agent to check its own interfaces every five seconds, and send a trap when one changes. Then Ana takes the router's internet line down. Five seconds later, a trap reaches the office: link down, on WAN, the internet line. The router called Ana before she asked.

Ana: office PC and router
date +%T; sudo ip link set wan down21:46:48
Ana: office PC and router
journalctl -u snmptrapd -o cat -n 721:46:53  trap from UDP: [192.168.71.1]:40229->[192.168.71.20]:162
    SNMPv2-MIB::sysUpTime.0 = Timeticks: (1001) 0:00:10.01
    SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkDown
    IF-MIB::ifIndex.12 = INTEGER: 12
    IF-MIB::ifDescr.12 = STRING: wan
    IF-MIB::ifOperStatus.12 = INTEGER: down(2)
    SNMPv2-MIB::snmpTrapEnterprise.0 = OID: SNMPv2-SMI::enterprises.8072.3.2.10

When the line comes back, another trap: link up. Polling tells you how busy things are. Traps tell you the moment something changes. Most setups use both.

Ana at the office PC
journalctl -u snmptrapd -o cat -n 721:46:58  trap from UDP: [192.168.71.1]:40229->[192.168.71.20]:162
    SNMPv2-MIB::sysUpTime.0 = Timeticks: (1501) 0:00:15.01
    SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkUp
    IF-MIB::ifIndex.12 = INTEGER: 12
    IF-MIB::ifDescr.12 = STRING: wan
    IF-MIB::ifOperStatus.12 = INTEGER: up(1)
    SNMPv2-MIB::snmpTrapEnterprise.0 = OID: SNMPv2-SMI::enterprises.8072.3.2.10

One manager, every device

And it's the same language on every device. One loop asks the router and the brewhouse server the same two questions, name and uptime, with the same community. A switch, a printer or a UPS answers them too, because every agent shares the same tree of addresses.

Ana at the office PC
for h in router brewhouse; do snmpget -v2c -c brew-mon $h sysName.0 hrSystemUptime.0; doneSNMPv2-MIB::sysName.0 = STRING: router
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (91233) 0:15:12.33
SNMPv2-MIB::sysName.0 = STRING: brewhouse
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (91242) 0:15:12.42

Before you leave it running

Before you leave it running: use version 3 where your devices support it. If you must use a community, make it secret, read-only, and accepted from your manager's address only. And keep the agent's port, 161, closed to everyone else.

Before you leave it running: cards of Version 3 where you can, A secret community, Read-only, from one address, Port 161 closed to others

Recap

So: the manager asks on port 161, and agents answer. Values have addresses, O I Ds, and MIBs name them. Speed is two counter readings, subtracted. Traps on 162 report changes. And version 3 keeps it private.

SNMP in five lines: diagram of Manager asks, agent answers, OIDs, named by MIBs, Speed = two readings, subtracted, Traps report changes, Version 3 keeps it private

If you can read your own router now, a like helps YouTube show this to more beginners, and subscribing brings more networks, explained on real machines.

Every answer, timeout and trap in this video came from real machines, and every command and the lab files are linked in the description. Thanks for watching Cloud Explainers.

Sources

Demos: five containers on our own Mac standing in for a craft brewery's router, server and PCs; the brewery and its passwords are made up. Every answer, timeout, trap and packet was real. Watch the full video on YouTube.

More videos

DevOps & CI/CD9 min

DevOps with Ansible Will Finally Make Sense After This

Git8 min

How to Fix GitHub 'Permission Denied (publickey)' Errors

PostgreSQL7 min

How to Fix PostgreSQL 'Password Authentication Failed'

Linux8 min

Why One Linux Server Handles More Users Than You Think

Networking7 min

How to Fix Network 'Connection Refused' Errors

DevOps & CI/CD9 min

DevOps Pipelines: Jenkins vs GitHub Actions

Networking11 min

Every Networking Term a Beginner Needs in 12 Minutes

Docker6 min

How to Fix Docker 'Permission Denied' on docker.sock

Git7 min

How to Fix Git 'Updates Were Rejected' When You Push

Linux7 min

How to Fix nginx 502 Bad Gateway Errors on Linux

Linux8 min

How to Fix Linux apt 'Could Not Get Lock' Errors (Ubuntu)

Networking9 min

How Email Works on the Internet (SMTP) in 10 Minutes

Python8 min

The Python Roadmap for Beginners

Go (Golang)21 min

Golang REST API with Gin: Full Tutorial for Beginners

Networking10 min

How a WireGuard VPN Network Works

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Active Directory9 min

How Active Directory Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Python9 min

Every Python Concept for Beginners in 10 Minutes

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio10 min

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python10 min

Python uv vs pip: Which One Should You Use?

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index