Thursday, October 27, 2016

SNMP Trap configuration on Ubuntu 12.04 LTS



SNMP Configuration on Ubuntu 12.04 LTS

Requires the NET SNMP packages installed

Configuring a trap receiver and sending an example v1 trap.

=== SNMP Trap Daemon ===
disable access control in /etc/snmp/snmptrapd.conf

disableAuthorization yes

=== SNMP Daemon ===

etc/snmp/snmpd.conf changes

agentAddress udp:161,udp6:[::1]:161

For v3 uncomment the create user lines


 === SNMP v1 Trap test ===

with debug output enabled

 snmptrap -d -v 1 -c public localhost   NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification "" 6 17 "" netSnmpExampleInteger i 123457

shows packet sent


Sending 66 bytes to UDP: [127.0.0.1]:162->[0.0.0.0]
0000: 30 40 02 01  00 04 06 70  75 62 6C 69  63 A4 33 06    0@.....public.3.
0016: 0A 2B 06 01  04 01 BF 08  02 03 01 40  04 0A A9 68    .+.........@...h
0032: C2 02 01 06  02 01 11 43  04 00 93 B6  94 30 13 30    .......C.....0.0
0048: 11 06 0A 2B  06 01 04 01  BF 08 02 01  01 02 03 01    ...+............
0064: E2 41

=== Trap in syslog ====

# tail -f /var/log/syslog

Oct 27 12:26:18 kspring-HP-Z210-Workstation snmptrapd[5096]: 2016-10-27 12:26:17 kspring-HP-Z210-Workstation.local [10.169.104.194] (via UDP: [127.0.0.1]:57412->[127.0.0.1]) TRAP, SNMP v1, community public#012#011iso.3.6.1.4.1.8072.2.3.1 Enterprise Specific Trap (17) Uptime: 1 day, 2:53:25.32#012#011iso.3.6.1.4.1.8072.2.1.1 = INTEGER: 123457

5 comments:

  1. For v2, add the notification mib file:

    vi /usr/share/mibs/netsnmp/NOTIFICATION-TEST-MIB.txt

    NOTIFICATION-TEST-MIB DEFINITIONS ::= BEGIN
    IMPORTS ucdavis FROM UCD-SNMP-MIB;

    demonotifs OBJECT IDENTIFIER ::= { ucdavis 991 }

    demo-notif NOTIFICATION-TYPE
    STATUS current
    OBJECTS { sysLocation }
    DESCRIPTION "Just a test notification"
    ::= { demonotifs 17 }

    END

    === SEND TRAP ===
    snmptrap -v 2c -c public localhost '' NOTIFICATION-TEST-MIB::demo-notif SNMPv2-MIB::sysLocation.0 s "testing123"

    ReplyDelete
  2. Oct 27 12:48:54 kspring-HP-Z210-Workstation snmptrapd[5096]: 2016-10-27 12:48:54 localhost [UDP: [127.0.0.1]:57057->[127.0.0.1]]:#012iso.3.6.1.2.1.1.3.0 = Timeticks: (9816226) 1 day, 3:16:02.26#011iso.3.6.1.6.3.1.1.4.1.0 = OID: iso.3.6.1.4.1.2021.991.17#011iso.3.6.1.2.1.1.6.0 = STRING: "testing123"

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. == V3 ==
    Add user to snmptrapd.conf
    createUser -e 0x0102030405 myuser MD5 DES
    restart


    snmptrap -e 0x0102030405 -v 3 -u myuser -a MD5 -A netbotzpassword -l authNoPriv localhost 42 coldStart.0

    === Log output:Oct 27 13:03:16 kspring-HP-Z210-Workstation snmptrapd[5296]: 2016-10-27 13:03:16 localhost [UDP: [127.0.0.1]:39431->[127.0.0.1]]:#012iso.3.6.1.2.1.1.3.0 = Timeticks: (42) 0:00:00.42#011iso.3.6.1.6.3.1.1.4.1.0 = OID: iso.3.6.1.6.3.1.1.5.1.0

    ReplyDelete
  5. http://www.cisco.com/c/en/us/about/press/internet-protocol-journal/back-issues/table-contents-20/snmpv3.html

    ReplyDelete