How to Install and Configure SNMP on CentOS (Step-by-Step Guide)





 


🔍 What is SNMP?

SNMP (Simple Network Management Protocol) is used to monitor and manage network devices such as routers, switches, and servers. Installing SNMP on CentOS allows you to track system performance and receive alerts through centralized monitoring tools.


Prerequisites

·         CentOS 7/8 system with root or sudo access

·         Access to terminal or SSH

·         Internet connection to install packages


🛠️ Step 1: Install SNMP and SNMP Utilities

First, install the required SNMP packages:

 
yum install net-snmp net-snmp-utils -y

These packages include:

·         net-snmp: Core SNMP daemon

·         net-snmp-utils: Command-line tools for testing SNMP


⚙️ Step 2: Configure SNMP

2.1 Backup the Default SNMP Configuration

It’s best to backup the original SNMP configuration before making changes:

 
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig

2.2 Create a New Configuration File

Create a blank configuration file:

 
touch /etc/snmp/snmpd.conf

Then edit the file using a text editor:

 
nano /etc/snmp/snmpd.conf

Paste the following configuration, replacing the community string with your own secure string (TtL*h!wHur in this example):

 
# Map the community string to a security name
# Format: sec.name  source    community
 
com2sec notConfigUser  default  TtL*h!wHur

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1 80
 
access  MyROGroup ""      any       noauth    exact  all none none
access  MyRWGroup ""      any       noauth    exact  all all none
 
view all    included  .1                               80

💡 Note: The community string acts like a password. Use a strong one for security.


🔄 Step 3: Start and Enable SNMP Service

Restart the SNMP daemon to apply changes:

 
service snmpd restart

Enable the SNMP service to start on boot:

 
chkconfig snmpd on

🔐 Step 4: Configure System Firewall for SNMP

To allow SNMP traffic through your firewall, run:

 
firewall-cmd --zone=public --add-port=161/udp --permanent
firewall-cmd --zone=public --add-port=161/tcp --permanent
firewall-cmd --zone=public --add-port=162/udp --permanent
firewall-cmd --zone=public --add-port=162/tcp --permanent
firewall-cmd --reload

These ports are essential for SNMP requests (port 161) and SNMP traps (port 162).


Conclusion

You’ve successfully installed and configured SNMP on CentOS. Your system is now ready to be monitored using SNMP-compatible tools like NagiosZabbix, or SolarWinds.

 Related Post




No comments

Powered by Blogger.