Configure SNMP in Debian

This post is pretty straight forward but I want to mention there is a trick you have to use in Debian to get everything working correctly after you have all your SNMP packages installed.  I didn’t realize this when I was setting this up the other day and it tripped me up for awhile.

So to start things off, we need SNMP and SNMPD on our systems.

sudo aptitude install snmp snmpd

We also need to update our SNMP settings to reflect the read only SNMP community string that we want to use.  The default is public but it has been criticized for being susceptible to security breaches so you should probably keep that in mind when setting up SNMP in your environment.

At the very minimum your snmpd.conf file should look something like the following:

rocommunity mysnmpstring

Once you have updated this you need to unbind your localhost so that it can be read by others on the network.  This is what tripped me up initially on my Debian box, I do not believe it is an issue in Ubuntu but if it is then you should be able to use these instructions as well.  To fix this problem you need to edit the /etc/default/snmpd file and chop off the from the SNMPDOPTS section.  When it is fixed it should look like this:

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/'

Now you just need to restart the SNMP service:

service snmpd restart

You can check your handy work when you are done to make sure everything is working correctly by using this command from either the local host or another machine with SNMP installed on it.

snmpwalk -v1 -cpublic HOSTNAME/IP

Hopefully this will save time for somebody in the future, it certainly tricked me.

Josh Reichardt

Josh is the creator of this blog, a system administrator and a contributor to other technology communities such as /r/sysadmin and Ops School. You can also find him on Twitter and Facebook.