snmptrapconfig

Last Updated : Mar 21, 2024 |

Syntax:

Use this command to configure SNMP traps. You can add, modify, or delete a trap.

  • For SNMP v1 and SNMP v2:

    snmptrapconfig -v 1|2 --inform|--trap --if <ipaddr or fqdn> [--old_ipaddrfqdn <ipaddr or fqdn>] [-i <ipaddr or fqdn>[--old_ipaddrfqdn <ipaddr or fqdn>] --port <number> --port <number> -c <comm_name> [-o <comm_name> ] --add | --delete | --change

where

-if: destination fqdn or IP address

--old_ipaddrfqdn: previous destination fqdn or IP address (Only valid with Change option or required when changing the destination for an entry.)

-v: SNMP version (1, 2, 3)

--inform: inform entry (v2 & v3 only)

--trap: trap entry

-i: destination IP address

--old_type: previous entry type (inform / trap) (only valid with the 'change' option, required when changing the user/community name)

--port: port Number (default is 162)

-c: v1/v2c Community name

-o: previous community/user name (only valid with the 'change' option, required when changing the user/community name.)

--add: Add trap

--delete: Delete trap

--change: Modify trap

  • For SNMP v3:

    snmptrapconfig -v 3 --inform|--trap --if <ipaddr or fqdn> [--old_ipaddrfqdn <ipaddr or fqdn>] [-i<ipaddr or fqdn>[--old_ipaddrfqdn <ipaddr or fqdn>] -u <user> [-o <user>] [-s authNoPriv|authPriv] [-a <auth_passwd] [--auth_prot <protocol>][-p <priv_passwd>] [-p --priv_prot <protocol>] --add | --delete | --change
    snmptrapconfig --help | -h

where

-v: SNMP version (1, 2, 3)

--trap: trap entry

-i: destination IP address

--old_ipaddr: previous destination IP address

-u: v3 user name

-o: Previous community/user name (only valid with the 'change' option, required when changing the user/community name).

-s: v3 security model (authNoPriv, authPriv)

-a: v3 authentication password

--auth_prot: v3 authentication protocol (MD5, SHA)

-p: v3 privacy password

--priv_prot: v3 privacy protocol

-e: Engine ID (used with --if option)

--add: add entry

--delete: delete entry

--change: change entry

--auth_list: list supported authentication protocols

--priv_list: list supported privacy protocols

--rclist: list possible return codes from this command

--rccode: obtain error string associated with a return code

--help | -h: usage (this)

snmptrapconfig called with no arguments will display the current configuration.

Note:

Using the -a and -p options with arguments on the command line poses a security risk as the passwords may be logged. Instead, use the -a and -p options without arguments to prevent the risk.

Example:

  • Version 1:

    snmptrapconfig –v 1 --trap -i 135.9.36.44 --port162-c public--add
    snmptrapconfig –v 1 --trap -i 135.9.36.43 --old_ipaddr 135.9.36.44--port 162 -c private -o public--change
    snmptrapconfig –v 1 --trap -i 135.9.36.43 --port 162
    -c private --delete
  • Version 2:

    snmptrapconfig –v 2 --trap -i 135.9.36.44 --port 162 -c public
    –add
    snmptrapconfig –v 2 --trap -i 135.9.36.43 --old_ipaddr 135.9.36.44 --port 162 -c private -o public--change
    snmptrapconfig –v 1 --trap -i 135.9.36.43 --port 162
    -c private --delete
  • Version 3:

    snmptrapconfig –v 3 --trap -i 135.9.36.44 -u user1 -sauthNoPriv-aauthpasswd--auth_protMD5-pprivpasswd --priv_prot DES --add
    snmptrapconfig –v 3 --trap -i 135.9.36.44 -u username-ouser1 -sauthNoPriv-aauthpasswd--auth_protMD5-pprivpasswd --priv_prot DES --change
    snmptrapconfig –v 3 --trap -i 135.9.36.44 -u username  --delete