Skip to content

Configure SNMP on linux

Sébastien Serre edited this page Mar 14, 2017 · 5 revisions

Configure SNMP on Linux

Install and start snmpd. The following example is made on a CentOS machine. Adapt to your own distribution.

$ sudo yum install net-snmp net-snmp-utils
$ sudo systemctl enable snmpd
$ sudo systemctl start snmpd

Edit /etc/snmp/snmpd.conf (This is a minimal config file giving all acess to the "superSecure" community).

#       sec.name   source        community
com2sec superAdmin default       superSecure

#       groupName      securityModel securityName
group   superGroup     v2c           superAdmin

#       name           incl/excl     subtree         mask(optional)
view    superView      included      .1

#       group          context sec.model sec.level prefix read          write  notif
access  superGroup     ""      v2c       noauth    exact  superView     none   none

Then restart the daemon:

$ sudo systemctl restart snmpd

Try:

$ snmpwalk -v 2c -c superSecure 127.0.0.1
[...]
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (6) 0:00:00.06
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
[...]

Et voila!