Ubuntu SNMP binding only to 127.0.0.1 (localhost) – How to fix

By default, when you install snmpd (this was tested on Ubuntu 10.04, not sure about other Linux variants), the daemon is set to listen only on 127.0.0.1 (localhost)

If you run chech the process, you can see this:

techedemic@demo:/etc/default$ ps awux | grep snmp
snmp     32753  0.3  2.0  47916  4948 ?        S    09:29   0:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1
sintrex  32757  0.0  0.3   7624   904 pts/0    S+   09:29   0:00 grep --color=auto snmp

To allow access to any machine from outside (make sure your company security policies allow for this), you need to edit the /etc/default/snmpd file as follows:

(I use vim, you can obviously use any text editor you want)

Step 1

#open the file
sudo vim /etc/default/snmpd
 
#change the following line..
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
 
#to look like this..
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
 
#save and quit
:wq

Step 2

#restart snmpd daemon
sudo /etc/init.d/snmpd restart

You will now be able to do snmp queries from any machine that can reach your host.

Add a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.