Configure SNMP Traps on a Cisco switch (logging to FreeBSD)

One of many topics covered by the CCNA exam is logging. Here is a quick guide on how to setup SNMP traps on a Cisco switch (an old 3560 to be exact) and how to send them to a central server. I will be doing this in my Cisco lab, which includes a laptop running FreeBSD which will receive the traps.
We have to start by installing Net-SNMP:

If we plan to do more than just look at SNMP traps in a lab then take a look at the post install tasks which explains how to set snmpd to autostart on boot:

One we are done with the install it is time to start the snmptrapd service. Since this is only a lab setup we will not configure authorization. Outside the lab we would not want leave the SNMP server open to everyone. Create the following config file:

In the file enter the following line:

Save and quit (:wq). We now want to start the SNMP trap server. To view output in the terminal use the first command, and to save the traps to a file use the second command:

We are now listening to traps. Time to connect to the switch and generate some messages. We enable SNMP traps with the following commands:

This will send all syslog messages that are informational and above. The log level (6 in this case) can be adjusted as needed. To see all available options for SNMP traps use “snmp-server enable traps ?”.

Switching back to the FreeBSD host we should now see some SNMP traps being generated and displayed to standard output: