LinuxCommandLibrary

snmpget

Retrieve SNMP object values from agents

TLDR

Get a single OID value using SNMPv2c

$ snmpget -v 2c -c [community] [host] [OID]
copy
Get system description from a device
$ snmpget -v 2c -c [public] [192.168.1.1] sysDescr.0
copy
Get multiple OID values in one request
$ snmpget -v 2c -c [community] [host] [OID1] [OID2] [OID3]
copy
Query using SNMPv3 with authentication
$ snmpget -v 3 -u [username] -l authNoPriv -a MD5 -A [password] [host] [OID]
copy
Query using SNMPv3 with authentication and encryption
$ snmpget -v 3 -u [username] -l authPriv -a SHA -A [authpass] -x AES -X [privpass] [host] [OID]
copy
Set timeout and retries
$ snmpget -v 2c -c [community] -t [5] -r [3] [host] [OID]
copy

SYNOPSIS

snmpget [options] agent OID [OID...]

DESCRIPTION

snmpget communicates with a network entity using SNMP GET requests to retrieve specific management information. It queries one or more Object Identifiers (OIDs) and returns their current values from the SNMP agent.
The tool supports SNMPv1, SNMPv2c, and SNMPv3. SNMPv1 and v2c use community strings for simple authentication, while SNMPv3 provides robust security with authentication (MD5/SHA) and encryption (DES/AES) options.
OIDs can be specified numerically (e.g., .1.3.6.1.2.1.1.1.0) or using MIB names (e.g., sysDescr.0). Scalar values require a .0 index suffix. Without it, snmpget will return an error.

PARAMETERS

-v version

SNMP version: 1, 2c, or 3.
-c community
Community string for SNMPv1/v2c authentication.
-u username
SNMPv3 security name (username).
-l level
SNMPv3 security level: noAuthNoPriv, authNoPriv, or authPriv.
-a protocol
SNMPv3 authentication protocol: MD5 or SHA.
-A passphrase
SNMPv3 authentication passphrase.
-x protocol
SNMPv3 privacy protocol: DES or AES.
-X passphrase
SNMPv3 privacy passphrase.
-t timeout
Timeout in seconds before retransmitting. Default: 1.
-r retries
Number of retries before giving up. Default: 5.
-p port
UDP port of the SNMP agent. Default: 161.
-m MIBLIST
Colon-separated list of MIB modules to load. Use ALL for all MIBs.
-M PATHLIST
Colon-separated list of directories to search for MIBs.
-O options
Output format options (e.g., n for numeric OIDs, q for quick print).

CONFIGURATION

/etc/snmp/snmp.conf

System-wide SNMP client configuration including default version, community strings, and MIB search paths.
~/.snmp/snmp.conf
Per-user SNMP client configuration overriding system defaults.
MIBS
Environment variable specifying which MIB modules to load (colon-separated list, or ALL).
MIBDIRS
Environment variable specifying directories to search for MIB files.

CAVEATS

Scalar OIDs require a .0 index suffix; omitting it is a common error. SNMPv1/v2c community strings are transmitted in plaintext and should only be used on trusted networks. For secure environments, use SNMPv3 with authentication and encryption. MIB files must be installed for symbolic OID names to work.

HISTORY

snmpget is part of the Net-SNMP project, an open-source suite of SNMP tools and libraries. Net-SNMP evolved from the CMU SNMP implementation in the 1990s and later the UCD-SNMP project. The project provides comprehensive SNMP v1, v2c, and v3 support and is widely used for network monitoring and management on Unix-like systems.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community