2. SNMP:
The Simple Network Management Protocol (SNMP) is an application-layer
protocol that provides a message format for communication between SNMP managers and agents. It
provides an agentless method of managing and monitoring of network devices and servers for health
information, system metrics such as CPU load, Physical Memory usage, number of running
processes, service states or any other metric that support polling over the SNMP protocol.
The SNMP framework has the following components, which are described in the following sections:
SNMP Manager:
The Simple Network Management Protocol (SNMP) manager is a system that controls
and monitors the activities of network hosts using SNMP. The most common managing system is a
network management system (NMS). The term NMS can be applied either to a dedicated device used
for network management or to the applications used on such a device.Several network management
applications are available for use with SNMP like simple command line interface applications.
SNMPAgent:
The Simple Network Management Protocol (SNMP) agent is the software component
within a managed device that maintains the data for the device and reports this data, as needed, to
managing systems. The agent resides on the routing device (router, access server, or switch).
3. SNMP MIB:
A management information base (MIB) is a database used for managing the entities
in a communication network. Most often associated with the Simple Network Management Protocol.
An SNMP agent contains MIB variables, whose values the SNMP manager can request or
change through Get or Set operations. A manager can get a value from an agent or store a value in
that agent. The agent gathers data from the SNMP MIB, the repository for information about device
parameters and network data. The agent can also respond to manager requests to get or set data. The
figure below illustrates the communications between the SNMP manager and agent. A manager sends
an agent requests to get and set the SNMP MIB values. The agent responds to these requests.
Independent of this interaction, the agent can send the manager unsolicited notifications (traps or
informs) to notify the manager about network conditions.
**NOTE**:The MIB variables are referred to as MIB Object Identifiers (OIDs). OID names are
hierarchy structured and unique. SNMP uses the OID to identify objects on each network element
(device running SNMP agent)
4. SNMP Operations:
The Simple Network Management Protocol (SNMP) applications perform the
following operations to retrieve data, modify SNMP object variables, and send notifications:
SNMP Get:
The Simple Network Management Protocol (SNMP) GET operation is performed by an
Network Management Server (NMS) to retrieve SNMP object variables.
SNMP SET:
The Simple Network Management Protocol (SNMP) SET operation is performed by a
Network Management Server (NMS) to modify the value of an object variable.
SNMP Notifications:
A key feature of Simple Network Management Protocol (SNMP) is its capability to
generate asynchronous notifications from an SNMP agent. Notifications can indicate improper user
authentication, restarts, the closing of a connection, loss of connection to a neighbor device, or other
significant events which can be generated as traps or inform requests (informs). Traps are messages
alerting the Simple Network Management Protocol (SNMP) manager to a condition on the network.
Informs are traps that include a request for confirmation of receipt from the SNMP manager. Traps
are less reliable than informs because the receiver does not send an acknowledgment when it receives
a trap.Traps are often preferred even though they are less reliable because informs consume more
resources in the device and the network.
6. SNMP supports three versions of SNMP protocol:
1) 1
2) 2c
3) 3
Both version 1 and 2c provides
authentication using community
string, a shared secret between
the agent and the client that is
passed in clear text over the
network.
Version 3 supports user
authentication and message
encryption using a variety of
protocols and is thus a bit more
secure.
7. Install SNMP on CentOS 8
yum update // If need update
yum install net-snmp net-snmp-libs net-snmp-utils
systemctl enable --now snmpd
systemctl status snmpd
cp /etc/snmp/snmpd.{conf,orig}
// The default configuration file of the Net-SNMP is /etc/snmp/snmpd.conf. The file is highly commented and
thus, we will only make a few changes. As a result, make a copy of the original file before you can proceed.
snmpwalk -v2c -c public localhost system
//provide default information like sysName, sysLocation and sysContact about system,also can use ip of the
server instead of localhost.
vim /etc/snmp/snmpd.conf
//To update this information,Note that the value of the sysName object is set to system hostname by default.
Hence, sysLocation and sysContact can be set in the configuration file, at last save the file.
systemctl reload snmpd
snmpwalk -v2c -c public localhost system //verify the changes
8. Configuring SNMP Version 2c Community on CentOS 8
SNMP v2 provides access using a permission directive, a community string and the source Address.
**syntax** directive community [source [OID]]
The source address can be IP of the SNMP server, directive can be rocommunity (provides read-only access) or
rwcommunity (provides read-write access), OID is the optional SNMP tree to provide access to.
rocommunity monsvronly 192.168.58.8 // IP of the remote server allowed access.
rocommunity monsvronly 127.0.0.1 //To allow from localhost, add the line;
//enter these lines in the snmpd config file.OR simply give the below command, one by one.
echo -e "# SNMP version 2c communitynrocommunity monsvronly 192.168.58.8" >> /etc/snmp/snmpd.conf
9. Configure SNMP Daemon Connection Port
By default, SNMP daemon agent receives requests on UDP port 161. SNMPd however does not open this port by
default.To configure SNMPd to listen on a loopback and an IP interface over UDP port 161, you need to edit the
snmpd systemd start-up script, /lib/systemd/system/snmpd.service
vim /lib/systemd/system/snmpd.service
Replace the line:
ExecStart=/usr/sbin/snmpd $OPTIONS -f
With;
ExecStart=/usr/sbin/snmpd $OPTIONS -f udp:127.0.0.1:161
udp:192.168.56.9:161
systemctl daemon-reload
systemctl restart snmpd
netstat -alun | grep 161 //Verify that the UDP port 161 is open.
10. Open SNMP Port on FirewallD
If firewalld is running, run the commands below to open SNMPd port
firewall-cmd --add-port=161/udp --permanent
firewall-cmd --reload
Verify Connectivity
Test connectivity from the allowed remote host.Check if the UDP port is reachable on the server.
nc -uvz 192.168.58.9 161
Test that you can query the SNMP objects on the server using the snmpwalk and read the first
10 lines of the output.
snmpwalk -v2c -c monsvronly 192.168.58.9 | head -10