Debian / Ubuntu Linux: Install and Configure snmpd Service

Posted on in Categories last updated February 2, 2010

SNMP (Simple Network Management Protocol) is a protocol used for network management. How do I install SNMP server under Debian or Ubuntu Linux to configure various monitoring service?

The NET-SNMP project provides various SNMP tools: an extensible agent, an SNMP library, tools for requesting or setting information from SNMP agents, tools for generating and handling SNMP traps, a version of the netstat command which uses SNMP, and a Tk/Perl mib browser. The snmpd package contains the snmpd and snmptrapd daemons, documentation, etc.

Install snmpd

Type the following command as root, enter:
# apt-get update && apt-get install snmpd

Snmpd Configuration Files

The default configuration for snmpd is rather paranoid for security reasons. Edit /etc/snmp/snmpd.conf or run snmpconf to allow greater access. You can individually control whether or not snmpd and snmpdtrap are run by editing /etc/default/snmpd.

Configure SNMPD

Edit /etc/snmp/snmpd.conf, enter:
# vi /etc/snmp/snmpd.conf
Edit or update file as follows:

rocommunity setMeHere
com2sec local     localhost           public
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
view all    included  .1                               80
access MyRWGroup ""      any       noauth    exact  all    all    none

com2sec notConfigUser  default       mrtg
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
view    systemview    included   .
view    systemview    included   .
view    systemview    included  .1                               80
access  notConfigGroup ""      any       noauth    exact  systemview none none

syslocation Mumbai, IN (VSNL LB3)
syscontact Vivek Gite <[email protected]>

See snmpd.conf(5) man page for details. Edit /etc/default/snmpd, enter:
# /etc/default/snmpd
Update it as follows:

# This file controls the activity of snmpd and snmptrapd
# MIB directories.  /usr/share/snmp/mibs is the default, but
# including it here avoids some strange problems.
export MIBDIRS=/usr/share/snmp/mibs
# snmpd control (yes means start daemon).
# snmpd options (use syslog, close stdin/out/err).
# replace 204.x.y.z with your public IP 
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/ 204.x.y.z'
# snmptrapd control (yes means start daemon).  As of net-snmp version
# 5.0, master agentx support must be enabled in snmpd before snmptrapd
# can be run.  See snmpd.conf(5) for how to do this.
# snmptrapd options (use syslog).
TRAPDOPTS='-Lsd -p /var/run/'
# create symlink on Debian legacy location to official RFC path

Restart Snmpd Service

Type the following command:
# /etc/init.d/snmpd restart
Sample outputs:

Restarting network management services: snmpd.

Firewall Configuration

Here is a sample firewall config file:

# set shell vars
# DROP and close everything all incoming traffic
# Allow Full Outgoing connection but no incoming stuff by default
# Unlimited lo access
### Open port 161 ###
$IPT -A INPUT -i ${PUB_IF} -s ${SNMPD_CLIENT} -d ${SNMPD_SERVER} -p udp --dport 161 -j ACCEPT
### rest of iptables goes here ###

Test It

From local or remote system type the following command:
# snmpwalk -v 1 -c mrtg 204.x.y.z IP-MIB::ipAdEntIfIndex
Sample outputs:

IP-MIB::ipAdEntIfIndex. = INTEGER: 2
IP-MIB::ipAdEntIfIndex. = INTEGER: 1
IP-MIB::ipAdEntIfIndex.204.xx.yy.zz = INTEGER: 3


  1. man pages – iptables, snmpd, snmpd.conf, apt-get

20 comment

  1. Hi,

    I’m looking to modify the snmpd.conf file so that I receive email notification when a printer toner is low

    SNMPv2-SMI::mib- = STRING: “The machine has determined that the Toner’s capacity is low. User intervention is required to replace the Toner to avoid an interruption of print service. Printing is available.

    Any ideas how this might be achieved?


  2. doesnt work, I made both my configuration files exactly how you demonstrated and this is what I get
    [email protected]:~# /etc/init.d/snmpd restart
    * Restarting network management services: [ OK ]
    [email protected]:~# snmpwalk -Os -c mycommunity -v 1 localhost system
    Timeout: No Response from localhost
    [email protected]:~#

  3. In newer versions of ubuntu snmpd is on localhost only, you have to modify /etc/default/snmpd and on the SNMPDOPTS parameter, remove the parameter. If you use smux (like with nagios), also remove -smux.

  4. does any one know how to install snmp throught the configure command and maybe explain a bit about the Export PATH=:$PATH…………
    P.S. I am new at this ..sorry!

  5. In squeeze the interface bindings are controlled via /etc/snmp/snmpd.conf not /etc/default/snmpd


    # Listen for connections from the local system only
    agentAddress udp:
    # Listen for connections on all interfaces (both IPv4 *and* IPv6)
    #agentAddress udp:161,udp6:[::1]:161

  6. Hi,
    SNMP is a great tool, but does exist a way in order to add a user specific OID (modifyng the tree)?
    Ex.: Users logged (as a STRING for the user account)


  7. Hi All ,

    This is a great site and I got a lot of help through this site …Thank you all …But i have a problem …I install Opennms in windows and installed snmp in ubuntu …My target is that I want to run a mib file …How to create and run a mib file…Please help me ..Thanking you in advance….

  8. This was very helpful. I striggled (and struggled!) with this for some time. for some reason one of my Ubuntu servers was different on the snmp side or I didn’t follow the same path on this attempt as I did on the first. The Ubunter Server versions were different 10.10 was my first success and 11.10 was the one I was having a problem with.
    The problem was /etc/default/snmpd
    Now along with my other servers this one can now join the ranks of being monitored by Nagios!
    Thanks again.

  9. Hello,
    # Snmpwalk-v 1-c mrtg IP-MIB :: ipadentıfındex I command we wrote this in my error message is coming.

    Error: MIB search path: /root/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
    Can not find module (IP-MIB): At line 0 in (none)
    IP-MIB :: ipadentifindex: Unknown Object Identifier

    It’s because I’m new like you wrote the script above, I did not know where and how Run for me I did not do. This error can be caused due from him?

    Can you be helping me in this matter?

  10. MIB search path: /root/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
    Cannot find module (IP-MIB): At line 0 in (none)
    IP-MIB::ipAdEntIfIndex: Unknown Object Identifier
    [email protected]:~# cat -iptables
    cat: invalid option — ‘i’
    Try `cat –help’ for more information.

  11. I doneonfiguration files (etc/default/snmpd exactly how you demonstrated and snmpd.conf:
    # Listen for connections on all interfaces (both IPv4 *and* IPv6)
    agentAddress udp:161,udp6:[::1]:161

    # source community
    com2sec local localhost public
    com2sec winet puplic

    # sec.model
    group mygroup v1 winet
    group mygroup v2c winet
    group local v1 local
    group local v2c local

    # incl/excl subtree mask
    view all included .1 80
    view sysView included system

    # context model level prefix read write notify
    access local “” any noauth exact system none all
    access mygroup “” any noauth exact all all all

    sysLocation xyz

    sysContact xxx
    sysServices 72
    # Process Monitoring
    proc mountd
    proc ntalkd 4
    proc sendmail 10 1
    # Disk Monitoring
    disk / 10000
    disk /var 5%
    includeAllDisks 10%
    # System Load
    load 12 10 5
    # send SNMPv1 traps
    trapsink localhost public
    # send SNMPv2c traps
    #trap2sink localhost public
    # send SNMPv2c INFORMs
    #informsink localhost public
    # Event MIB – automatically generate alerts
    # Remember to activate the ‘createUser’
    rouser internalUser
    # generate traps on UCD error conditions
    defaultMonitors yes
    # generate traps on linkUp/Down
    linkUpDownNotifications yes
    # AgentX Sub-agents
    # Run as an AgentX master agent
    master agentx
    # Listen for network connections (from localhost)
    # rather than the default named
    #agentXSocket tcp:localhost:705
    but when run snmpwalk :
    $ snmpwalk -v 1 -c public localhost system
    End of MIB
    what i missed on snmpd.conf??

Leave a Comment