- How To Install and Configure SNMP on CentOS
- How To Change the SNMP Port on CentOS
SNMP, or Simple Network Management Protocol, is widely used to communicate with and monitor network devices, servers, and more, all via IP. In the previous article, we installed an SNMP agent on a CentOS 6.5 server. This agent allows for the collection of data from our server and makes the information available to a remote SNMP manager. To add a little security, we’ll now change the port that SNMP listens on.
- These instructions are intended for changing the SNMP port.
- I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.
- SNMP is installed and configured per the tutorial on How To Install and Configure SNMP on CentOS.
Change the SNMP Port
First, echo a new configuration into the SNMP configuration file:
echo OPTIONS=\"-LS0-5d -Lf /dev/null -p /var/run/snmpd.pid -x TCP:13371 UDP:13371\" >> /etc/sysconfig/snmpd
-LS0-5d specifies the logging level. In this case levels 0 through 5 will be logged; log levels are defined as follows:
0 or ! for LOG_EMERG,
1 or a for LOG_ALERT,
2 or c for LOG_CRIT,
3 or e for LOG_ERR,
4 or w for LOG_WARNING,
5 or n for LOG_NOTICE,
6 or i for LOG_INFO, and
7 or d for LOG_DEBUG.
-p /var/run/snmpd.pid saves the process ID of the daemon into /var/run/snmpd.pid.
-x TCP:13371 UDP:13371 listens on port 13371 (TCP and UDP) on all IPv4 interfaces. Port 13371 was used specifically for this tutorial, and can be replaced with a custom report number.
Now, restart the SNMP service to reload the new configuration file:
service snmpd restart
To verify that SNMP is now listening on the correct port use the following command:
netstat -lnp | grep snmp
Let’s test the SNMP configuration… try running the following two commands:
snmpwalk -v 2c -c idv90we3rnov90wer -O e 127.0.0.1:13371