How to Install SNMP on RHEL/CentOS

SNMP (Simple Network Management Protocol) is widely used for network management and monitoring. Installing SNMP on RHEL/CentOS systems allows you to monitor various system statistics, interfaces, and other crucial metrics. This guide will walk you through the detailed steps to install, configure, and test SNMP on your RHEL/CentOS system. Whether you’re setting it up for monitoring purposes or integrating with a larger network management system, this tutorial will provide you with all the essential steps.

In this tutorial you will learn:

  • How to install SNMP on RHEL/CentOS
  • How to enable and start the SNMP service
  • How to check the status of the SNMP service
  • How to test SNMP functionality from localhost
  • How to open the firewall for SNMP traffic
  • How to test SNMP from a remote system
How to Install SNMP on RHEL/CentOS
How to Install SNMP on RHEL/CentOS
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL/CentOS 7/8/9
Software net-snmp, net-snmp-utils
Other Access to the internet and a user with root privileges
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Step-by-Step Guide to Install and Configure SNMP on RHEL/CentOS

Below are the steps required to install and configure SNMP on your system. This will allow your server to be monitored remotely via SNMP, which is useful for network management tools.

  1. Install SNMP: The first step is to install the SNMP packages on your RHEL/CentOS system. The SNMP software includes net-snmp and net-snmp-utils.
    # yum install net-snmp net-snmp-utils

    This command installs the SNMP service and utilities required to manage and interact with SNMP on your system.

  2. Enable SNMP: After the installation, you need to enable the SNMP service to ensure it starts on boot.
    # systemctl enable snmpd

    This command ensures that the SNMP service will automatically start when your system boots, making sure it is always available for monitoring.

  3. Start SNMP: Once SNMP is enabled, start the service to make it active.
    # systemctl start snmpd

    Starting the SNMP service initiates the process and makes your system ready for SNMP requests.

  4. Check SNMP Status: Verify that the SNMP service is running correctly.
    # systemctl status snmpd

    This command checks the current status of the SNMP service to ensure it is active and running without errors.



  5. Test Connection from Localhost using snmpwalk: To ensure SNMP is working correctly, you can test it locally using the snmpwalk command.
    # snmpwalk -v2c -c public localhost

    This command queries the SNMP service on your local machine. The -v2c option specifies the SNMP version, and -c public is the community string used for authentication. If SNMP is functioning correctly, you should see a series of SNMP data outputs.

    Test Connection from Localhost using snmpwalk
    Test Connection from Localhost using snmpwalk
  6. Open Firewall for SNMP: If you want to allow SNMP traffic from remote machines, you need to open the firewall to allow SNMP traffic.
    # firewall-cmd --permanent --add-port=161/udp
    # firewall-cmd --reload

    This command opens port 161 (the default SNMP port) for UDP traffic on your system’s firewall, allowing SNMP queries from remote systems. The second command reloads the firewall to apply the changes.

  7. Test SNMP from Remote System: Finally, to ensure SNMP is accessible remotely, you can test it from another system using snmpwalk.
    $ snmpwalk -v2c -c public <server-ip>

    Replace <server-ip> with the IP address of your RHEL/CentOS server. If SNMP is correctly configured, you will receive SNMP data from the remote server.

Conclusion

By following the steps outlined above, you have successfully installed and configured SNMP on your RHEL/CentOS system. You are now able to monitor your system locally and remotely using SNMP. This setup is crucial for integrating with network monitoring systems, ensuring your infrastructure is well-managed and maintained. Remember to regularly check and update your SNMP configuration as needed to adapt to any changes in your network.