How to install snmp on RHEL 8 / CentOS 8 step by step instructions

The net-snmp package is available in the base repositories after enabling Subscription Management repositories.

  1. First we need to install the package containing the snmpd service:# dnf install net-snmp
  2. To set the service to automatic start on boot, we use systemctl:# systemctl enable snmpd
  3. Let’s start the service:# systemctl start snmpd
  4. And verify it’s running state:# systemctl status snmpd -l snmpd.service - Simple Network Management Protocol (SNMP) Daemon. Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-01-02 19:29:35 CET; 25min ago Main PID: 3217 (snmpd) Tasks: 1 (limit: 12544) Memory: 8.4M CGroup: /system.slice/snmpd.service 3217 /usr/sbin/snmpd -LS0-6d -f
  5. To test it, we’ll need the snmpwalk utility:# dnf install net-snmp-utils
  6. To test it from the command line, we’ll query the default public community („rhel8lab“ in the answer is the hostname of the lab machine):$ snmpwalk -v 2c -c public -O e 127.0.0.1 SNMPv2-MIB::sysDescr.0 = STRING: Linux rhel8lab 4.18.0-32.el8.x86_64 #1 SMP Sat Oct 27 19:26:37 UTC 2018 x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (174237) 0:29:02.37 SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) SNMPv2-MIB::sysName.0 = STRING: rhel8lab [...]
  7. For remote access, we need to add a new service to firewalld. We create the text file /etc/firewalld/services/snmpd.xml with the following content:

    <?xml version="1.0" encoding="utf-8"?> <service> <short>SNMPD</short> <description>SNMP daemon</description> <port protocol="udp" port="161"/> </service>Open the firewall for the service:# firewall-cmd --zone=public --add-service snmpd --permanentAnd reload the firewall’s configuration:# firewall-cmd --reload
  8. Now we can query the machine remotely the same way as we did on localhost:$ snmpwalk -c public -v3c 192.168.0.91 <hostname-or-ip-address-of-the-machine>

Source: https://linuxconfig.org/how-to-install-snmp-on-redhat-8

Jan D.
Jan D.

"The only real security that a man will have in this world is a reserve of knowledge, experience, and ability."

Articles: 677

Leave a Reply

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *