Setting the IP Source Address for SNMP Traps
Problem
You want to set the source IP address for all SNMP traps leaving a router.
Solution
To set the default IP source address for all traps leaving a router, use the following configuration command:
Router#configure terminalEnter configuration commands, one per line. End with CNTL/Z. Router(config)#snmp-server hostRouter(config)#172.25.1.1 ORATRAPsnmp-server trap-sourceRouter(config)#loopback0endRouter#
Discussion
Normally, when you enable SNMP traps to a remote server, that server will see the source IP address of the router’s closest interface. However, this is not always meaningful. For instance, it is a relatively common practice to populate your DNS with only the router’s loopback interfaces. In this case, the server will not be able to resolve the originator of the trap.
Further, it can be difficult to correlate traps from the same router delivered through different interfaces. This could happen as a result of a network failure, for example. It can be confusing to see a link-down message coming from one IP address and the corresponding link-up message from a different one.
By enabling the snmp-server trap-source command, you can force the router to always use the same IP source address for all of the SNMP traps it sends. Industry best practices dictate that a loopback interface is usually the best choice for this because it is a virtual interface that is always available. Physical interfaces such as Ethernet or Serial interfaces ...