Configuring SNMP on Linux
Tutorial aimed at enabling a basic configuration of SNMP services on Linux operating systems.
Installation
Section titled “Installation”Systems using yum
Section titled “Systems using yum”While logged in as root, in the Linux terminal type:
yum install net-snmpSystems using apt-get
Section titled “Systems using apt-get”While logged in as root, in the Linux terminal type:
apt-get install snmpdConfiguring the snmpd.conf file
Section titled “Configuring the snmpd.conf file”Generally, the snmpd.conf file is located at /etc/snmp/. Back up the original file:
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.oldEdit the new file (example with vim: vim /etc/snmp/snmpd.conf) as the lines below:
rocommunity publicsysLocation “Localização deste servidor”sysContact seu@email.com.brRestart and enable the SNMP service
Section titled “Restart and enable the SNMP service”Systems with Systemd
Section titled “Systems with Systemd”In the terminal, type:
systemctl restart snmpdsystemctl enable snmpdSystems with System V
Section titled “Systems with System V”In the terminal, type:
service snmpd restartAllow the SNMP service through the Linux firewall
Section titled “Allow the SNMP service through the Linux firewall”If the Linux server or workstation you want to monitor has a firewall enabled, to access the SNMP service add the example below to the firewall rules of that device. If your distribution manages the firewall differently, open the incoming UDP/161 port.
firewall-cmd --permanent --zone=public --add-port=161/udpsystemctl restart firewalld