(Optional) Configuring the Trap Function
Context
Users can enable the trap function for a specified module. The interface status trap is generated when the interface status changes. You need to enable the trap function for the ifnet module globally and enable the trap function on the specified interface.
Procedure
- Run system-view
The system view is displayed.
- Enable the trap function.
Enable the trap function for a module:
To enable the trap function of all modules, run the snmp-agent trap enable command.
To enable the trap function of a specified module, run the snmp-agent trap enable feature-name command.
To restore the trap functions of all modules to the default status, run the undo snmp-agent trap enable or undo snmp-agent trap disable command.
- To delete the trap configurations related to a function, run the clear configuration snmp-agent trap enable feature-name feature-name command.
Enable the trap function for an interface:
Run snmp-agent trap enable feature-name ifnet [ trap-name { linkdown | linkup } ]
The trap function is enabled on all interfaces.
By default, the trap function is disabled on all interfaces. When the linkdown and linkup parameters are configured, the device sends a trap to the NMS upon an interface status change. If the interface status frequently changes, the interface frequently sends traps to the NMS, subjecting the NMS to a heavy load. To combat this problem, disable the interface status trap function on the interface. The procedure is as follows:
Run the interface interface-type interface-number command to enter the interface view.
Run the undo enable snmp trap updown command to disable the interface status trap function.
Run the quit command to return to the system view.
- Run snmp-agent notify-filter-profile { excluded | included } profile-name oid-tree
A trap filtering rule is created or updated.
By default, traps are not filtered.
- Run snmp-agent trap source interface-type interface-number
The source interface for sending traps is specified.
By default, source interface of traps is not set. After the source interface is specified, the IP address of the source interface is used as the source IP address for sending traps. This helps the NMS identify the trap source. The source interface that sends traps must have an IP address; otherwise, the command will fail to take effect. To ensure device security, it is recommended that you set the source IP address to the local loopback address.
The source interface set on the switch must be consistent with that specified on the NMS. Otherwise, the NMS does not accept the traps sent from the switch.
- Run snmp-agent trap source-port port-number
The source port to send trap is set.
The source port needs to be fixed. Packets can be filtered by a firewall to improve network security.
- Run commit
The configuration is committed.