snmpget
Retrieve data from SNMP enabled devices
TLDR
Request a single value from the SNMP agent
Display the full Object Identifier (OID) path
Display help
SYNOPSIS
snmpget [COMMON OPTIONS] [AUTHENTICATION OPTIONS] AGENT OID [OID...]
PARAMETERS
AGENT
The hostname, IP address, or domain name of the target SNMP agent (network device or server) to query.
OID
The Object Identifier (OID) of the specific management information to retrieve. OIDs can be numerical (e.g., '.1.3.6.1.2.1.1.5.0') or textual (e.g., 'sysName.0') if MIBs are loaded.
-v <1|2c|3>
Specifies the SNMP protocol version to use for the request.
1 for SNMPv1, 2c for SNMPv2c, and 3 for SNMPv3.
-c COMMUNITY
For SNMPv1 or SNMPv2c, specifies the community string (a plaintext password) required to access the SNMP agent.
-u USER
For SNMPv3, specifies the security name (username) for authentication.
-l LEVEL
For SNMPv3, specifies the security level:
noAuthNoPriv (no authentication, no encryption)
authNoPriv (authentication, no encryption)
authPriv (authentication and encryption).
-a PROTOCOL
For SNMPv3, specifies the authentication protocol: MD5 or SHA.
-A PASSPHRASE
For SNMPv3, specifies the authentication passphrase for the user.
-x PROTOCOL
For SNMPv3, specifies the privacy (encryption) protocol: DES or AES.
-X PASSPHRASE
For SNMPv3, specifies the privacy (encryption) passphrase for the user.
-t TIMEOUT
Sets the timeout in seconds before retransmitting a request. Default is 1 second.
-r RETRIES
Sets the number of retries before giving up. Default is 5 retries.
-p PORT
Specifies the UDP port number of the SNMP agent. Default is 161.
-M PATHLIST
Specifies a colon-separated list of directories to search for MIB files.
-m MIBLIST
Specifies a colon-separated list of MIB modules to load. Use 'ALL' to load all MIBs in the search path.
-Oq
Output option: Suppress MIB parsing, print only the OID and value.
-Of
Output option: Print the full OID, including the enterprise name (if available).
DESCRIPTION
The snmpget command is a powerful utility within the Net-SNMP suite, used to retrieve a single specific piece of management information from a network device or server that supports the Simple Network Management Protocol (SNMP). It achieves this by sending an SNMP GET request to the target SNMP agent. The command requires the address of the SNMP agent and the Object Identifier (OID) of the specific data point to be retrieved.
It supports various SNMP versions, including SNMPv1, SNMPv2c, and SNMPv3, with increasing levels of security and functionality. For SNMPv1 and SNMPv2c, a 'community string' is typically required for authentication, acting like a password. SNMPv3 offers robust security features like authentication (MD5, SHA) and encryption (DES, AES), making it suitable for secure environments. snmpget is fundamental for network monitoring, troubleshooting, and automation scripts that need to fetch specific status or configuration parameters from network infrastructure.
CAVEATS
Using snmpget requires that the target network device has an SNMP agent running and properly configured to allow queries from the source IP.
Firewalls must permit UDP traffic (typically port 161) between the querying machine and the SNMP agent.
For SNMPv1/v2c, the 'community string' is often transmitted in plaintext, posing a security risk if intercepted. Always use SNMPv3 when possible for enhanced security through authentication and encryption.
SNMP VERSIONS AND SECURITY
SNMPv1 and SNMPv2c use 'community strings' for basic authentication, which are sent in plaintext and offer no encryption. This makes them vulnerable to eavesdropping and unauthorized access.
SNMPv3 provides robust security features including authentication (MD5, SHA) and encryption (DES, AES), ensuring data integrity, origin authentication, and confidentiality. It is highly recommended for sensitive environments.
OBJECT IDENTIFIERS (OIDS) AND MIBS
An OID (Object Identifier) is a hierarchical identifier used to uniquely name objects in a Management Information Base (MIB). MIBs are essentially databases that describe the structure of management data and define objects (variables) that can be queried or manipulated on an SNMP agent.
While snmpget can query using numerical OIDs, loading relevant MIB files (using -M and -m options) allows you to use more human-readable textual OIDs, simplifying the process of identifying and retrieving specific information.
HISTORY
snmpget is a core component of the Net-SNMP project, an open-source suite of applications and libraries for implementing SNMP (Simple Network Management Protocol). Developed by the Net-SNMP community, it has been a staple tool for network administrators and developers since its early days, evolving alongside SNMP protocol versions (v1, v2c, v3). Its widespread adoption is due to its reliability, comprehensive feature set, and cross-platform availability, making it an indispensable utility for interacting with SNMP-enabled devices.
SEE ALSO
snmpwalk(1), snmpbulkget(1), snmpset(1), snmpnext(1), snmpd(8)