Configure SNMP in CentOS
[Plain] view plaincopyprint?
- <Spanstyle = "font-size: 14px;"> This article describes how to configure a simple SNMP Service in the CentOS environment </span>
Software Installation
Switch to the system administrator account
Install snmp
Check that the snmp agent is installed.
Rpm-q net-snmp
If not, install snmp
Yum install net-snmp
Set automatic snmp running upon startup
/Sbin/chkconfig snmpd on Configure snmp
Modify configuration file
Back up the original configuration file and edit/etc/snmp/snmpd. conf. The simple configuration is as follows:
[Plain] view plaincopyprint?
- # First, mapthecommunityname "public" using a "securityname"
- # Sec. namesourcecommunity
- Com2secnotconfiguserdefapublic public
- ####
- # Second, mapthesecuritynamepolicagroupname:
- # GroupNamesecurityModelsecurityName
- GroupnotConfigGroupv1notConfigUser
- GroupnotConfigGroupv2cnotConfigUser
- ####
- # Third, createaviewforustoletthegrouphaverightsto:
- # Makeatleastsnmpwalk-v1localhost-cpublicsystemfastagain.
- # Nameincl/exclsubtreemask (optional)
- Viewsystemviewincluded.1.3.6.1.2.1.1
- Viewsystemviewincluded.1.3.6.1.2.1.25.1.1
- ####
- # Finally, grantthegroupread-onlyaccesstothesystemviewview.
- # Groupcontextsec. modelsec. levelprefixreadwritenotif
- AccessnotConfigGroup "" anynoauthexactsystemviewnonenone
Start snmp
/Etc/init. d/snmpd start
Restart the snmp service if it has been started.
/Etc/init. d/snmpd restart
Test snmp
Check whether the port is enabled
Netstat-ln | grep 161
Install the snmp Test Tool
Yum install net-snmp-utils
Test snmp data on the local machine (modify monit to the group name configured)
Snmpwalk-v 2c-c public localhost system
Snmpwalk-v3-u username-l auth-a MD5-A password localhost
Create an SNMP (v3) User
Net-snmp-config -- create-snmpv3-user-ro-a MD5 lyceemsnmp lyceem.com
Remote Test of snmp data (modify the ip address to the server ip address, and install net-snmp for the snmpwalk command)
Snmpwalk-v 2c-c public ip system
Troubleshooting: if the local test snmp has data and the Remote Test snmp has no data, the server firewall prohibits external access to port udp 161 of the server:
Modify/etc/sysconfig/iptables (or:/etc/sysconfig/iptables-config) and add the following rules:
-A RH-Firewall-1-INPUT-p udp-m state Cstate NEW-m udp Cdport 161-j ACCEPT
Restart iptables
/Etc/init. d/iptables restart