Objective
Install SNMP, back up existing configuration, apply a fresh working config, and ensure connectivity.
1. Install Required Packages
yum install -y net-snmp net-snmp-utils
2. Backup Existing Configuration
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak 2>/dev/null
3. Create New SNMP Configuration
cat > /etc/snmp/snmpd.conf << 'EOF'
agentAddress udp:161
rocommunity public
sysLocation "Server"
sysContact "root@localhost"
EOF
4. Enable & Restart SNMP Service
systemctl enable snmpd
systemctl restart snmpd
5. Allow SNMP Port in Firewall
firewall-cmd --add-port=161/udp --permanent
firewall-cmd --reload
6. Adjust SELinux (if Enforcing)
setsebool -P snmpd_disable_trans 1
7. Verify Service Status
systemctl status snmpd
8. Test SNMP Locally
snmpwalk -v2c -c public localhost
9. Test SNMP Remotely
snmpwalk -v2c -c public <server-ip>
Expected Result
-
SNMP responds without timeout
-
Data (OID tree) is returned
Notes
-
Community string:
public(open access) -
Suitable for testing/monitoring only
-
Not recommended for production without restrictions
