SNMPv1 and SNMPv2 use community strings to restrict SNMP access. When you associate it with an SNMP group, you can restrict the access of MIBs for SNMPv1 and SNMPv2c requests.
device# configure terminal
device(config)# snmp-server view view2 1.3.6.1 included
device(config)# snmp-server group admin v2c write view2 notify view2
device(config)# snmp-server community comm1 group admin
This example adds the comm1 community string and associates it with the admin group to access the MIBs for SNMPv2c requests.
device(config)# snmp-server host 10.32.147.6 comm1 version 2c severity-level Warning
This example configures 10.32.147.6 as a trap recipient with SNMPv2c on the default target port 162 and associates the comm1 community string.
device(config)# snmp-server enable trap
device(config)# exit
device# show running-config snmp-server snmp-server contact "Operator 12345" snmp-server enable trap snmp-server location "Building 3 Room 214" snmp-server community comm1 group admin snmp-server group admin v2c write view2 notify view2 snmp-server host 10.32.147.6 comm1 version 2c severity-level Warning !
The following example shows the previous steps to configure SNMPv2.
device# configure terminal device(config)# snmp-server location "Building 3 Room 214" contact "Operator 12345" device(config)# snmp-server view view2 1.3.6.1 included device(config)# snmp-server group admin v2c write view2 notify view2 device(config)# snmp-server community comm1 group admin device(config)# snmp-server host 10.32.147.6 comm1 version 2c severity-level Warning device(config)# snmp-server enable trap