May 15, 2007

snmptrap command

snmptrap -v 1 -c public 192.168.100.40 1.2.3.4 192.168.254.60 3 0 ''

syntax:

-v 1: version 1
-c public: use community string "public"
192.168.100.40: trap manager's IP address (trap destination)
1.2.3.4: enterprise (i.e. type of device/object generating trap, default to system ID in mib II, can be empty)
192.168.254.50: trap source IP address (device's IP address)
3: generic trap ID, they are:
  • coldStart(0),
  • warmStart(1),
  • linkDown(2),
  • linkUp(3),
  • authenticationFailure(4),
  • egpNeighborLoss(5),
  • enterpriseSpecific(6)

0: specific trap ID, 0 when generic trap ID is not 6
'': system up time (timestamp)

You can also add "mib type value" to the end of the command to send them along with the trap

v2 trap:
snmptrap -v 2c -c public 192.168.100.40 "" 1.2.3.4.0

"": system Uptime (when given as empty "", the system finds itself)
1.2.3.4.0: trap OID

again, add "mib type value" to the end if you want.


v3 trap:

snmptrap -v 3 -a SHA -A 1234567890 -x DES -X 1234567890 -l authPriv -u myuser -e "123abc" 192.168.100.1 "" linkUp.0

---
Update (09/10/2013)

When running snmptrap command, and seeing warning message like:

    read_config_store open failure on /var/lib/net-snmp/snmpapp.conf

is okay. The trap is still being sent.

To run a debug catch-all snmptrapd:

     snmptrapd -Le -On -f -n

with the following just-one-line in /etc/snmp/snmptrapd.conf
    disableAuthorization yes

-n: no DNS lookup
-f:  no fork
-On: print numeric OID
-Le: log to standard error

10 comments:

  1. Thanks for this I was coming to the end of my tether with this command line syntax.

    ReplyDelete
  2. snmptrap command for version 3?

    ReplyDelete
  3. hey i have tried this :
    c:/usr/bin>snmptrap -v 1 -c demopublic localhost 1.2.3.4 localhost .1.3.6.1.2.1.1.1.0 3 0"
    i'm using net-snmp agent. and to receive the traps i'm using manageEngineopUtlis 6. but not receiving any traps. urgent help needed.

    ReplyDelete
  4. Hey why there is no port no is mentioned in the below?
    snmptrap -v 1 -c public 192.168.100.40 1.2.3.4 192.168.254.60 3 0

    ReplyDelete
  5. Thank you. Thank you. Thank you. This helped me tremendously just now....

    ReplyDelete
  6. Thanks - my head was starting to bleed from banging it against the wall ;)

    Andy.

    ReplyDelete
  7. Has anyone tried to send v3 via AES privacy protocol? I would appreciated some help if so.

    ReplyDelete
    Replies
    1. AES should work. I have used it before. It's not working for you?

      Delete
  8. thanks, it's very easy to understand

    ReplyDelete