How to use SNMP spoof to mimic the behaviour of an SNMP trap
Use the "request snmp spoof-trap <TRAP_NAME>" operational mode command to mimic SNMP trap behaviour. The contents of the traps (the values and instances of the objects carried in the trap) can be specified on the command line or automatically spoofed. This feature is useful to trigger SNMP traps from routers and ensure that they are processed correctly within your existing network management infrastructure, but you might find it difficult to simulate the error conditions that trigger many of the traps on the node.
This is also useful for testing and debugging SNMP behaviour on the node or NMS.
The request snmp spoof-trap trap <name> command is for simulating a trap to the NMS, which normally receives the device’s traps. You can also add required values by using the variable-bindings parameter. For more information, refer to the following link:
https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/command/request-snmp-spoof-traps-command.html
A snippet from a lab node for usage reference:
root@router-re0> request snmp spoof-trap ?
Possible completions:
<trap> The name of the trap to spoof
adslAtucInitFailureTrap
adslAtucPerfESsThreshTrap
---(more 3%)---[abort]
root@router-re0# show snmp | display set | no-more
set snmp traceoptions file TEST_SNMP
set snmp traceoptions flag all
root@router-re0> request snmp spoof-trap jnxRmonAlarmGetFailure
Spoof-trap request result: trap sent successfully
root@router-re0> show log TEST_SNMP
Jan 18 04:40:55.238361 snmpd[0] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Jan 18 04:40:55.238368 snmpd[0] <<< V2 Trap
Jan 18 04:40:55.238375 snmpd[0] <<< Source: 10.85.248.154
Jan 18 04:40:55.238382 snmpd[0] <<< Destination: 1.1.1.1
Jan 18 04:40:55.238388 snmpd[0] <<< Version: SNMPv3
Jan 18 04:40:55.238394 snmpd[0] <<< Security Parameters:
Jan 18 04:40:55.238399 snmpd[0] <<< SecModel: USM
Jan 18 04:40:55.238409 snmpd[0] <<< EngId: 80 00 0a 4c 01 0a 55 f8 9c
Jan 18 04:40:55.238415 snmpd[0] <<< User: superuser
Jan 18 04:40:55.238423 snmpd[0] <<< EngBoots: 7 EngTime: 6401
Jan 18 04:40:55.238430 snmpd[0] <<<
Jan 18 04:40:55.238447 snmpd[0] <<< OID : sysUpTime.0
Jan 18 04:40:55.238454 snmpd[0] <<< type : TimeTicks
Jan 18 04:40:55.238462 snmpd[0] <<< value: (640139) 1:46:41.39
Jan 18 04:40:55.238468 snmpd[0] <<<
Jan 18 04:40:55.238482 snmpd[0] <<< OID : snmpTrapOID.0
Jan 18 04:40:55.238489 snmpd[0] <<< type : Object
Jan 18 04:40:55.238500 snmpd[0] <<< value: jnxRmonAlarmGetFailure
Jan 18 04:40:55.238506 snmpd[0] <<<
Jan 18 04:40:55.238518 snmpd[0] <<< OID : alarmIndex.32768
Jan 18 04:40:55.238524 snmpd[0] <<< type : Number
Jan 18 04:40:55.238531 snmpd[0] <<< value: 32768
Jan 18 04:40:55.238537 snmpd[0] <<<
Jan 18 04:40:55.238558 snmpd[0] <<< OID : alarmVariable.32768
Jan 18 04:40:55.238565 snmpd[0] <<< type : Object
Jan 18 04:40:55.238573 snmpd[0] <<< value: jnxRmonTraps
Jan 18 04:40:55.238579 snmpd[0] <<<
Jan 18 04:40:55.238592 snmpd[0] <<< OID : jnxRmonAlarmGetFailReason.32768
Jan 18 04:40:55.238599 snmpd[0] <<< type : Number
Jan 18 04:40:55.238605 snmpd[0] <<< value: 12
Jan 18 04:40:55.238611 snmpd[0] <<<
Jan 18 04:40:55.238619 snmpd[0] <<< OID : snmpTrapEnterprise.0
Jan 18 04:40:55.238626 snmpd[0] <<< type : Object
Jan 18 04:40:55.238636 snmpd[0] <<< value: jnxProductNameMX240
Jan 18 04:40:55.238641 snmpd[0] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<