Network Management
How to configure SNMP on Linux and Unix
This article describes how to configure SNMP on Linux/UNIX type systems
First published date
Last published date
Overview
This article describes how to configure SNMP on Linux/UNIX type systems.
The most common SNMP configuration on Linux/UNIX is by using the net-snmp package maintained by http://www.net-snmp.org/. Installing and configuring net-snmp varies slightly depending on the specific Linux/UNIX distribution you are working with.
Keep in mind that as your OS changes over time so does the documentation. If something stops working, it is always worth checking to see if there have been changes in the documentation, as well as any important changes are usually updated before new packages are released.
Product section
Resolution
Identify what UNIX / Linux system you are using. To check what UNIX / Linux version you have you can run any of the below commands:
|
|
Once distribution and version are established you need to check the distribution-specific documentation. Below is a table of eight common UNIX and Linux distributions and links to its documentation.
| DISTRIBUTION NAME | DOCUMENTATION URL |
|---|---|
| centOS 7 | See RedHat 7 documentation |
| centOS 6 | See RedHat 6 Documentation |
| centOS 5 and older | https://www.centos.org/docs/ |
| RedHat (all versions) | https://access.redhat.com/documentat...erprise-linux/ |
| ubuntu (all versions) | https://help.ubuntu.com/ |
| SUSE (all versions) | https://www.suse.com/documentation/ |
| ESXi 6 | https://pubs.vmware.com/vsphere-60/index.jsp |
| ESXi 5.5 | https://pubs.vmware.com/vsphere-55/index.jsp |
| ESXI 5 | https://pubs.vmware.com/vsphere-50/index.jsp |
| AIX 7.2 | https://www.ibm.com/support/knowledg...welcome_72.htm |
| AIX 7.1 | https://www.ibm.com/support/knowledg...welcome_71.htm |
| IBM CMM Modules | http://flexsystem.lenovofiles.com/he...duct_page.html |
| HP-UX 11i | https://h20565.www2.hpe.com/portal/s...4ts.oid=417289 |
| Arch Linux | https://wiki.archlinux.org/index.php/snmpd |
For an SNMPv3 configuration example on CentOS 7, see Configure SNMPV3 on Linux for SAM polling.
Additional Resources
Simple Configuration Example
The main configuration file for net-snmp is /etc/snmp/snmpd.conf
Some distributions or administrators might choose a different location for this file, but the content and syntax is the same. Here is a working SNMPv2 example from one of our labs.
# Map 'idv90we3rnov90wer' community to the 'ConfigUser' # Map '209ijvfwer0df92jd' community to the 'AllUser' # sec.name source community com2sec ConfigUser default idv90we3rnov90wer com2sec AllUser default 209ijvfwer0df92jd # Map 'ConfigUser' to 'ConfigGroup' for SNMP Version 2c # Map 'AllUser' to 'AllGroup' for SNMP Version 2c # sec.model sec.name group ConfigGroup v2c ConfigUser group AllGroup v2c AllUser # Define 'SystemView', which includes everything under .1.3.6.1.2.1.1 (or .1.3.6.1.2.1.25.1) # Define 'AllView', which includes everything under .1 # incl/excl subtree view SystemView included .1.3.6.1.2.1.1 view SystemView included .1.3.6.1.2.1.25.1.1 view AllView included .1 # Give 'ConfigGroup' read access to objects in the view 'SystemView' # Give 'AllGroup' read access to objects in the view 'AllView' # context model level prefix read write notify access ConfigGroup "" any noauth exact SystemView none none access AllGroup "" any noauth exact AllView none none
|
The above example is noted with basic information on the function of each configuration line. In short, we’re creating two scenarios for polling information from SNMP version 2c:
In the first scenario
ConfigUser is assigned to ConfigGroup and may only use the SNMP security model 2c, ConfigGroup can use the SystemView, SystemView is assigned to two OID sub-trees, and all of this is referenced in an SNMP poll by the secret and unique community string idv90we3rnov90wer.
In the second scenario
AllUser is assigned to AllGroup and may only use the SNMP security model 2c, AllGroup can use the AllView, AllView is assigned to the entire OID tree, and all of this is referenced in an SNMP poll by the secret and unique community string 209ijvfwer0df92jd.
Note 1: For additional information about allowed syntax in this file please see official documentation from net-SNMP maintainers: http://www.net-snmp.org/docs/readmefiles.html
Note 2: In the newest Linux versions, you may also configure the AgentAddress and rocommunity
agentaddress udp:161 rocommunity public 0.0.0.0/0
If the Linux is configured to use IPV6, then you should add the following lines:
agentaddress udp6:161 rocommunity6 public ::/0
Any changes to this file will require a restart of the snmpd service
# service snmpd restart
to ensure net-snmp service is running across each restart:
#' chkconfig snmpd on |