Configuring SNMP Agents on different Linux Servers
Monitor your Linux servers agentless, with the support of SNMP. Simply install and configure SNMP agents on your servers, install an On-Premise Poller, and your server for monitoring.
Linux flavors
Ubuntu
Installation
Execute the command:
> apt update
> apt install snmpd
Configuration
Edit the file: /etc/snmp/snmpd.conf
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
rocommunity public - #agentAddress udp is the IP address from which SNMP requests will be accepted by the server. Hence, comment the line:
#agentAddress udp:127.0.0.1:161 - For the same reason mentioned above, uncomment the line:
agentAddress udp:161,udp6:[::1]:161 - Restart the SNMP Service:
service snmpd restart
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
Allowing SNMP ports in firewall
Execute the following commands to allow necessary ports:
ufw allow 161/udp
ufw allow 162/udp
CentOS
Installation
Execute the commands:
> yum update
> yum install net-snmp
Configuration
Edit the file: /etc/snmp/snmpd.conf
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
rocommunity public - Replace the line below:
view systemview included .1.3.6.1.2.1.25.1.1
with the following line:
view systemview included .1.3. - Restart the SNMP Service:
service snmpd restart
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
Allowing SNMP ports in Firewall
Execute the commands:
firewall-cmd --zone=public --add-port=161/udp --permanent
firewall-cmd --zone=public --add-port=162/udp --permanent
firewall-cmd --reload
Oracle Solaris
Execute the command:
svcadm enable net-snmp
FreeBSD
1. Fetching Ports Collection
The FreeBSD operating system offers Ports Collection as a simple way to install SNMP applications.
Execute the commands:
portsnap fetch
portsnap extract
2. Installing net-snmp
cd /usr/ports/net-mgmt/net-snmp
make install clean
Click OK on the next screen and wait for the installation to complete.
3. Configuration file
- Copy the following configuration file:
cp /usr/local/share/snmp/snmpd.conf.example /usr/local/etc/snmpd.conf - Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
rocommunity public - #agentAddress udp is the IP address from which SNMP requests will be accepted by the server. Hence, comment the line:
#agentAddress udp:127.0.0.1:161 - For the same reason mentioned above, uncomment the line:
agentAddress udp:161,udp6:[::1]:161
- Copy the following configuration file:
4. Firewall configuration
Edit the /etc/rc.conf file and add the following lines:
snmpd_enable="YES"
snmpd_conffile="/usr/local/etc/snmpd.conf"
5. Starting the SNMP Service
service snmpd start
RHEL
Installation
- Execute the command:
yum install -y net-snmp - Set the SNMP v1 Read-Only Community String as 'public' by adding the line below to the configuration file (/etc/snmp/snmpd.conf):
rocommunity public - #agentAddress udp is the IP address from which SNMP requests will be accepted by the server. Hence, comment the line:
agentAddress udp:161,udp6:[::1]:161 - Start the snmpd service:
systemctl enable snmpd && systemctl start snmpd
- Execute the command:
Allowing SNMP ports in firewall
Execute the following commands:
firewall-cmd --zone=public --add-port=161/udp --permanent
firewall-cmd --zone=public --add-port=162/udp --permanent
firewall-cmd --reload
Debian
Installation
Execute the commands:
> apt update
> apt install snmpd
Configuration
Edit the file: /etc/snmp/snmpd.conf
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
rocommunity public - #agentAddress udp is the IP address from which SNMP requests will be accepted by the server. Hence, comment the line:
#agentAddress udp:127.0.0.1:161 - For the same reason mentioned above, uncomment the line:
agentAddress udp:161,udp6:[::1]:161 - Restart the snmpd service:
/etc/init.d/snmpd restart
- Set the SNMP v1 Read-Only Community String as 'public' by adding the line:
Fedora
Installation
- Execute the following command:
> yum install net-snmp - Set the SNMP v1 Read-Only Community String as 'public' by adding the line below to the configuration file (/etc/snmp/snmpd.conf):
rocommunity public - Restart the snmpd service:
/bin/systemctl restart snmpd.service
- Execute the following command:
Firewall Configuration
Excecute the following commands to allow the necessary ports:
firewall-cmd --zone=public --add-port=161/udp --permanent
firewall-cmd --zone=public --add-port=162/udp --permanent
firewall-cmd --reload
Replace the word "public" with the active zone name.
macOS
Configuration
- Edit the SNMP configuration file (/etc/snmp/snmpd.conf) and set the SNMP v1 Read-Only Community String as 'public' by adding the line:
rocommunity public - Start the snmp service:
sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
- Edit the SNMP configuration file (/etc/snmp/snmpd.conf) and set the SNMP v1 Read-Only Community String as 'public' by adding the line:
Testing SNMP on Linux
Test the SNMP reachability using MIB browser
Related articles
-
On this page
- Linux flavors
- Ubuntu
- CentOS
- Oracle Solaris
- FreeBSD
- RHEL
- Debian
- Fedora
- macOS
- Related articles