SNMP: The Network Management Protocol
Introduction
Network management systems are based on three main elements: a supervisor, nodes, and agents. In SNMP terminology, the term “manager” is more commonly used than “supervisor”. The supervisor is the console that allows the network administrator to execute management requests. Agents are entities located at each interface, connecting the managed equipment (node) to the network and allowing information to be retrieved on different objects.
Switches, hubs, routers, workstations, and servers (physical or virtual) are examples of equipment containing manageable objects. These manageable objects can be hardware information, configuration parameters, performance statistics, and other objects that are directly related to the current behavior of the equipment in question. These objects are classified in a tree-like database called MIB (Management Information Base). SNMP enables communication between the supervisor and agents to collect the desired objects in the MIB.
The network management architecture proposed by the SNMP protocol is therefore based on three main elements:
- The managed devices are network elements (bridges, switches, hubs, routers or servers) containing “managed objects” which can be hardware information, configuration elements or statistical information
- The agents, which are network management applications residing in a device, are responsible for transmitting the local management data of the device in SNMP format
- Network management systems (NMS), which are the consoles through which administrators can perform administration tasks
Versions
There are 3 versions of the SNMP protocol:
- V1: The first version uses communities to have access to the protocol
- V2: This version suffers from incompatible implementations (no standards, each manufacturer does as they wish)
- V3: Uses USM (User Security Model) to improve security on:
- Hashed user authentication
- Encryption of data in transit
Management of Information Bases
SNMP contains hierarchical information in a database for each device. The data is encapsulated as objects called OIDs represented by:
- A table that can contain multiple values
- A scalar for a single value
- 2 types of integers for:
- Counters: non-negative integer, increases to max, then values are reset to zero
- Gauges: negative or non-negative integer, remains at the max value
Installation
Client
Debian
On Debian, we’ll need the snmp package:
|
|
Red Hat
On Red Hat, we’ll need to install the net-snmp-utils package:
|
|
Server
Debian
On Debian, we’ll need the snmpd package:
|
|
Red Hat
On Red Hat, we’ll need to install the net-snmp package:
|
|
Configuration
Server v1
For a server in v1 configuration, you can configure access using the snmpconf command or the configuration file:
|
|
The first line allows anybody to access the rocommunity. The second allows write access to the 192.168.0.0/24 range.
If you use the snmpconf command, create a configuration file. But first, you’ll need to move the current one because the command might cause problems otherwise.
Server v3
Version 3 of the SNMP protocol is different from version 1 in its operation. Before starting, we will stop the SNMP server and it’s very important that it is stopped for the following steps:
|
|
We’ll then install the development package to have a very useful tool on Red Hat:
|
|
We’ll need to create a user to whom we’ll assign rights (the password must be >= 8 characters):
|
|
Here we see that the net-snmp-config tool modified the configuration file by adding the username user. It also registered other information in the /var/lib/net-snmp/snmpd.conf
file.
Now let’s create rights for this user. For that we’ll need to create:
- A group: we’ll define a group to integrate users
- A view: this view will be used to specify what the defined group is authorized to see (in relation to an SNMP tree)
- Access: we map access and authentication methods to the group and the chosen view
|
|
Pay attention to the order of insertion of the lines, they are important for the configuration to work.
Then start the SNMP service:
|
|
MIBs
MIBs are translated in this form:
The definition of a MIB is therefore in the following form:
- Prefix: IP-MIB::ipForwarding.0 (the 0 is mandatory for scalar values, otherwise it doesn’t work)
- Numeric ID: .1.3.6.1.2.1.4.1.0
- The full name of the object: .iso.org.dod.internet.mgmt.mib-2.ip.ipForwarding.0
The last number is an index corresponding to the value of the OID (indexes working like arrays in Perl):
Reading a MIB
For reading, let’s take the example of Linux MIBs:
|
|
- ip OBJECT IDENTIFIER ::= { mib-2 4 }: Corresponds to the SNMP prefix
- ipForwarding OBJECT-TYPE: importing dependencies, such as OBJECT-TYPE
- DESCRIPTION: we have a description
snmpget
SNMP v1
To retrieve the value of this object, we’ll use the snmpget command which is used to retrieve a single value:
|
|
- -v: We specify the protocol version here (1)
- -c: the community to use (check the server configuration to know it)
Note: If you don’t get anything, it’s probably because you have a permission problem on the server side.
SNMP v3
We’ve just seen for version 1, now for version 3:
|
|
- -l: This is the type of security we want for SNMPv3
- auth: password for hashed and therefore encrypted authentication
- priv: password for data encryption
- authPriv: allows using both types of encryption (authentication + data)
- authNoPriv: Having authentication without data encryption.
- -u: the username to use for authentication
- -A: the passphrase for user authentication
- -a: the hash algorithm to use for authentication
- -X: the passphrase shared with the server
- -x: the encryption algorithm to use for the shared secret
Note: If you don’t get anything, it’s probably because you have a permission problem on the server side.
If you often have multiple requests to make to the same host, you can create a file that can only contain a single host in ~/.snmp/snmp.conf
or /etc/snmp/snmp.conf
:
|
|
Now, you no longer need to pass all your arguments, simply the server with the MIB.
snmpwalk
Snmpwalk will retrieve all values. You’ll need to use grep to find the value you want:
|
|
snmpnetstat
This tool will retrieve OIDs and display them like the netstat command:
|
|
Finding MIB Objects
The snmptranslate command will help us find MIB objects installed locally on the machine (/usr/share/snmp/mibs/*
). For example, to perform a tree search:
|
|
If we want a numeric version:
|
|
For a complete tree version:
|
|
Last updated 25 Dec 2011, 20:37 +0200.