How to Configure SNMP Version 2c on Debian 9

Last Updated:

Welcome to our tutorial on how to configure SNMP version 2c on Debian 9. If you are looking at monitoring your Debian servers via SNMP with tools like Nagios, Cacti etc, then you need to configure SNMP. In that case, you are at the right place. In our previous articles discusses configuration of SNMP on Ubuntu 18.04 and CentOS 7.

Configuring SNMP Version 2c on Debian 9

To configure SNMP on Debian 9, you need to install the necessary packages. For example, the snmp which provides SNMP command line client applications, snmpd which is the daemon providing SNMP services and other required libraries.

apt update
apt install snmpd snmp libsnmp-dev

Once the packages above are installed, proceed to configure SNMP on Debian 9. To kick off with, you need to define the method in which the SNMP clients on the monitoring servers will connect to the SNMP agents on the Debian 9 server to poll specific requests.

The most common authentication methods involves the use community string and User-based Security Model. While the former is used with SNMP protocols version 1 and 2c the later is used by  SNMP protocol version 3.

Configure SNMP Version 2c Community String

SNMP v2 provides access using a permission directive, a community string and the source Address. The syntax of this directive is define below;

directive community [source [OID]]


  • directive can be set to rocommunity (provides read-only access) or rwcommunity (provides read-write access)
  • community is a user ID or password-like string that allows access to server statistics
  • source is the IP address of the monitoring server
  • OID is the optional SNMP tree to provide access to.

Hence, make a backup of the SNMP configuration file, /etc/snmp/snmpd.conf before you can make changes to the original configuration file.

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

Create a new SNMP daemon configuration file.

touch /etc/snmp/snmpd.conf

Configure SNMP deamon to listen on a public IP interface. By default, it only listens on a loopback interface. Hence, edit the line below to set it to listen on both loopback and public IP interface so that it can be access by the monitoring server.

vim /etc/snmp/snmpd.conf


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

Next, you need to configure SNMP version 2c community string used to allow access to statistics within the server. In this case, we are going to set a string that allows read only access from the monitoring server. The syntax of the string is explained above.


                                                 #  system + hrSystem groups only
view   systemonly  included   .
view   systemonly  included   .

                                                 #  Full access from the local host
#rocommunity public  localhost
                                                 #  Default access to basic system info
 rocommunity public  default    -V systemonly
                                                 #  rocommunity6 is for IPv6
 rocommunity6 public  default   -V systemonly
# Read only Access from monitoring server (
 rocommunity MyStrinG+   

If any firewall is running, be sure to open the ports and allow access from the monitoring server.
Restart the SNMP service.

systemctl restart snmpd

Check the ports are now listening

ss -alnp | grep snmp | grep 161
udp    UNCONN     0      0                   *:*                   users:(("snmpd",pid=6149,fd=12))
udp    UNCONN     0      0                   *:*                   users:(("snmpd",pid=6149,fd=9))

The configuration of SNMP version 2c is done. Let us now verify that everything is fine. The verification can be done locally and from the monitoring server using the snmpwalk tool which retrieve a subtree of management values using SNMP GETNEXT requests

From the localhost, you can verify that all is well by running the command below.

snmpwalk -v2c -c public localhost

iso. = STRING: "Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64"
iso. = OID: iso.
iso. = Timeticks: (19557) 0:03:15.57
iso. = STRING: "Me <[email protected]>"
iso. = STRING: "debian"
iso. = STRING: "Sitting on the Dock of the Bay"
iso. = INTEGER: 72
iso. = Timeticks: (1) 0:00:00.01

From the remote monitoring host, you can run the commanad as shown below, specifying the string.

snmpwalk -v2c -c MyStrinG+ | head -10

iso. = STRING: "Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64"
iso. = OID: iso.
iso. = Timeticks: (64405) 0:10:44.05
iso. = STRING: "Me <[email protected]>"
iso. = STRING: "debian"
iso. = STRING: "Sitting on the Dock of the Bay"
iso. = INTEGER: 72
iso. = Timeticks: (1) 0:00:00.01
iso. = OID: iso.
iso. = OID: iso.

If you are using Nagios and would like to monitor other system metics like uptime, disk load, logged in users etc, check our previous article by following the link below;

Nagios SNMP Monitoring of Linux Hosts

You may also be interested in our articles on Nagios monitoring;

How to Install and Configure Nagios Core From repo Ubuntu 18.04

How to Install and Configure Nagios Core From the Source Ubuntu 18.04

How to Install and Configure NSClient++ Nagios Agent on Windows System

How to Install Nagios NRPE Agent on RHEL/CentOS/Oracle Linux

How to Install Nagios Plugins From Source RHEL/CentOS/Oracle Linux

Configure Nagios Availability Monitoring on AlienVault USM/OSSIM


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
I am the Co-founder of, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment