01SNMP & MIBs in 60 seconds
An SNMP agent on a device exposes values in a tree addressed by OIDs
(numeric, e.g. .1.3.6.1.2.1.1.3.0). A MIB is a text file that names
those OIDs and describes their type and meaning (SNMPv2-MIB::sysUpTime.0). MIBs
IMPORT definitions from other MIBs, so a vendor MIB usually depends on several base
ones. "MIB management" is simply making sure the right MIB files are present and resolvable on the
box where you run snmp* — that's what turns numbers into names.
named object = numeric OID + MIB (name dictionary)
02Install the toolchain & base MIBs
Install the net-snmp clients, then the standard IETF/IANA MIBs. On Debian those MIBs are in the non-free component and are disabled by default.
# Debian / Ubuntu sudo apt install snmp snmp-mibs-downloader # clients + a downloader for standard MIBs sudo download-mibs # fetch the IETF/IANA MIB set # Standard MIBs are disabled by default via /etc/snmp/snmp.conf: # mibs : <-- comment this line out (or set 'mibs +ALL') to load names # RHEL / Rocky / Alma sudo dnf install net-snmp-utils # ships the base MIBs under /usr/share/snmp/mibs
03Where MIBs live & how they're found
net-snmp looks in a search path. Know these locations and the two ways to point at extra MIBs.
/usr/share/snmp/mibs # system base MIBs (IETF/IANA) ~/.snmp/mibs # your personal MIBs (no root needed) /opt/mibs/<vendor> # a good home for vendor MIBs (see next section) export MIBDIRS=/usr/share/snmp/mibs:$HOME/.snmp/mibs:/opt/mibs/fortinet # search path snmptranslate -M +/opt/mibs/fortinet -m +FORTINET-FGT-MIB -Tp # -M adds a dir, -m loads a module # Persist for all tools in ~/.snmp/snmp.conf (per-user) or /etc/snmp/snmp.conf (system): # mibdirs +/opt/mibs/fortinet # mibs +FORTINET-FGT-MIB
04Organize vendor MIBs — best practice
Vendor MIBs are where things get messy. A little structure keeps them resolvable and reproducible.
- One directory per vendor, under version control. Keep
/opt/mibs/<vendor>/(or a repo) so every poller loads the same, known MIB set. - Ship the dependencies with them. A vendor MIB
IMPORTSbase SMI and other modules — put them in the same search path so imports resolve. - Don't pollute
/usr/share/snmp/mibs. Prefer~/.snmp/mibsor a projectMIBDIRS; a package update won't wipe your work and it stays portable. - Avoid a global
mibs +ALLon busy hosts. It parses every MIB on every command (slow, noisy warnings). Load only what you need with-m/mibs +MODULE. - Validate on import (next section) before wiring a MIB into monitoring.
05Validate & explore MIBs with snmptranslate
This tool never touches the network — it just parses MIBs. It's your linter and your dictionary.
snmptranslate -On SNMPv2-MIB::sysUpTime.0 # name -> numeric OID snmptranslate -Of .1.3.6.1.2.1.1.3.0 # numeric -> full dotted name snmptranslate -Td IF-MIB::ifOperStatus # full definition (type, values, description) snmptranslate -Tp IF-MIB::ifTable # print the OID subtree of a MIB snmptranslate -IR sysName # fuzzy lookup by object name snmptranslate -M +/opt/mibs/fortinet -m +FORTINET-FGT-MIB -Tp # confirm a vendor MIB parses # A clean subtree = the MIB loaded. "Cannot find module (X): At line ..." = a missing IMPORT.
$ snmptranslate -On SNMPv2-MIB::sysUpTime.0 .1.3.6.1.2.1.1.3.0
06Query devices — put the MIBs to work
With MIBs loaded you can walk and poll by name. Prefer snmpbulkwalk (GETBULK) on
v2c/v3 — far fewer round-trips than snmpwalk.
snmpstatus -v2c -c '<community>' host # quick device health snmpget -v2c -c '<community>' host SNMPv2-MIB::sysName.0 snmpbulkwalk -v2c -c '<community>' host IF-MIB::ifTable # efficient bulk walk snmptable -v2c -c '<community>' host IF-MIB::ifTable # same data, tabular # SNMPv3 (preferred) — authPriv with SHA + AES: snmpwalk -v3 -l authPriv -u monitor \ -a SHA -A '<authpass>' -x AES -X '<privpass>' \ host SNMPv2-MIB::system
$ snmpwalk -v2c -c '<community>' host SNMPv2-MIB::system SNMPv2-MIB::sysDescr.0 = STRING: Linux edge01 5.15.0-107-generic x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 SNMPv2-MIB::sysUpTime.0 = Timeticks: (18294312) 2 days, 2:49:03.12 SNMPv2-MIB::sysContact.0 = STRING: noc@example.com SNMPv2-MIB::sysName.0 = STRING: edge01.example.com
07Security best practices
MIB management is half the job; querying safely is the other half.
SNMPv3 authPriv = user + auth (SHA) + priv (AES)
- Use SNMPv3 (
authPriv, SHA + AES). v1/v2c send the community string in cleartext — avoid them on any untrusted path. - Read-only, least privilege. A dedicated monitoring user/community with a scoped
read
VIEW, restricted to your poller's source IPs. - Filter the transport. Allow UDP/161 only from the monitoring subnet at the host and network firewall.
- Keep credentials out of scripts. Pull communities/passphrases from env or a vault — see the secrets section of the shell & environment guide.
- Rotate community strings and v3 passphrases periodically.
08Troubleshooting
The four errors you'll actually hit, and what they mean.
| Unknown Object Identifier (Sub-id not found) | The MIB naming that object isn't loaded — check MIBDIRS / -m. |
|---|---|
| Cannot find module (X): At line … | A required IMPORTS dependency is missing from the search path — add its MIB file. |
| Output shows numeric OIDs, not names | Base MIBs not installed, or mibs : is still set in snmp.conf — run download-mibs and enable them. |
| Timeout: No Response from host | UDP/161 blocked, wrong SNMP version, or wrong community/credentials — not a MIB problem. |
09Where to go next
Once names resolve cleanly, MIB work is repeatable: version the vendor MIBs, set MIBDIRS
in your poller's environment, and feed credentials from a vault. Sharpen the surrounding shell
skills in the Linux commands guide and the
shell & environment guide, or head back to the
Knowledge Base.