# Notes - SNMP Traps

SNMP notifications are unsolicited messages to an NMS. There are two types of SNMP notifications: traps and informs. A trap is not acknowledged, and an inform requires an acknowledge.



Generally, traps are preferred over informs. Traps use less resources, because informs must be held in memory in case they must be retransmitted due to being un-acknowledged.



## IOS-XE <a href="#b57771b4-d692-416d-8e36-8fc7d1794ace" id="b57771b4-d692-416d-8e36-8fc7d1794ace"></a>

On IOS-XE, we enable SNMP notifications using the following command. This is required for both traps and informs. Trap types such as **aaa\_server**, **config**, **cpu**, etc. can be used. If you do not specify anything, all traps are enabled.

```
snmp-server enable traps [trap type]
```



Next you must configure at least one NMS to receive the traps using the following configuration:

```
snmp-server host 1.1.1.1 traps|informs version <SNMP version> [trap types]
```



To disable SNMP linkup/linkdown notifications on a per-interface basis we use:

```
int Gi3
 no snmp trap link-status
```

\


The source interface for traps can be set using:

```
snmp-server trap-source interface
```



### Example 1 <a href="#id-92d2de8b-f8b7-44dd-840a-39535f1c9c8a" id="id-92d2de8b-f8b7-44dd-840a-39535f1c9c8a"></a>

```
snmp-server enable traps snmp linkdown linkup
snmp-server enable traps config
snmp-server host 155.1.146.101 version 2c CISCO
```



Above, we limit what events can generate SNMP notifications using the “snmp-server enable traps” command. Then we enable traps to be sent to the NMS at 155.1.146.101 using the v2c community CISCO. Note that by default traps are enabled for a host, which is why the “traps” keyword is not used.



We can verify using **show snmp host**:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2Fu3HsP2NxadEvVdyz6Ho4%2Fimage.png?alt=media&#x26;token=789b1a7f-84db-49dd-b199-8f1bb0e5d9d9" alt=""><figcaption></figcaption></figure></div>



### Example 2 <a href="#id-31b9386d-af9f-45b6-a5db-21a9835cfa4e" id="id-31b9386d-af9f-45b6-a5db-21a9835cfa4e"></a>

```
snmp-server enable traps
snmp-server host 155.1.146.101 version 2c CISCO config snmp
```



In this example, we enable all traps but limit the trap types on a per-NMS basis.



Note that this will fill your config with many lines of snmp-server enable trap commands.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FR7IOlE48chhIG3rMrf1f%2Fimage.png?alt=media&#x26;token=08dbb3d1-be2a-40a2-ba91-1d4d8a6b8bdb" alt=""><figcaption></figcaption></figure></div>



## IOS-XR <a href="#b09ac043-ebcf-48b3-b3ed-c8ae9e3db95d" id="b09ac043-ebcf-48b3-b3ed-c8ae9e3db95d"></a>

Configuration appears to be extremely similar for IOS-XR. The only difference I see is that you use the syntax “snmp-server traps” instead of “snmp-server enable traps.”



Additionally, to disable SNMP notifications for linkup/linkdown on a per-interface basis, you use:

```
snmp-server interface GigabitEthernet0/0/0/0
 notification linkupdown disable
```



### Example <a href="#id-0fffae13-afe0-4cf3-a2eb-69abfe126e24" id="id-0fffae13-afe0-4cf3-a2eb-69abfe126e24"></a>

```
snmp-server host 1.1.1.1 traps version 2c CISCO
snmp-server traps snmp linkup
snmp-server traps snmp linkdown
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FyAcxPLaBD16E3TIN474v%2Fimage.png?alt=media&#x26;token=75e61743-79d9-49cc-b213-21f4419cbf83" alt=""><figcaption></figcaption></figure></div>
