May 15, 2007

snmptrap command

snmptrap -v 1 -c public 3 0 ''


-v 1: version 1
-c public: use community string "public" trap manager's IP address (trap destination) enterprise (i.e. type of device/object generating trap, default to system ID in mib II, can be empty) 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 ""

"": system Uptime (when given as empty "", the system finds itself) 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" "" 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


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

  2. snmptrap command for version 3?

  3. hey i have tried this :
    c:/usr/bin>snmptrap -v 1 -c demopublic localhost localhost . 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.

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

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

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


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

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

  8. thanks, it's very easy to understand