I installed snmp on CentOS 7.2, like so:
yum -y install net-snmp net-snmp-utils
I made a backup of my snmpd.conf file:
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
then I cleared the text, with this:
echo "" > /etc/snmp/snmpd.conf
and added to the snmpd.conf, the following:
rocommunity "#random$" monitoring_server_ip
The monitoring_server_ip is the server that that is allowed to connect to this snmpd server.
Restarted snmpd
/bin/systemctl restart snmpd
When I run snmpwalk on my CentOS 7.2 server
snmpwalk -v2c -c public localhost system
I then get:
Timeout: No Response from localhost
Which is accurate, because there is only one IP-adres that can do that, as we have defined before.
ps shows that snmp is running
/usr/sbin/snmpd -LS0-6d -f
This is my first time playing with snmp and any help is greatly appreciated!
output of iptables -L -n | grep udp shows this:
...
Chain IN_public_allow (1 references)
94 target prot opt source destination
95 ACCEPT udp -- XX.XXX.XXX.XXX 0.0.0.0/0 udp dpt:161 ctstate NEW
...
All of the destination was too 0.0.0.0/0?
Netstat shows the following port:
netstat -ulnp | grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:* 19062/snmpd
also this:
netstat -lu | grep snmp
udp 0 0 0.0.0.0:snmp 0.0.0.0:*
Also, in my firewall, added that only one IP-adres can access my snmp server:
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="XX.XXX.XXX.XX" port protocol="udp" port="161" accept"