snmp-server community

Configures the SNMP community string and access privileges.
Syntax
snmp-server community community-string { ro | rw } [ acl-name | acl-num | ipv6 ipv6-acl-name | view [ mib-view ] ]
no snmp-server community community-string { ro | rw } [ acl-name | acl-num | ipv6 ipv6-acl-name | view [ mib-view ] ]
Command Default

The SNMP community string is not configured.

Parameters
community-string
Configures the SNMP community string that you must enter to gain SNMP access. The string is an ASCII string and can have up to 32 characters.
ro
Configures the community string to have read-only ("get") access.
rw
Configures the community string to have read-write ("set") access.
acl-name
Filters incoming packets using a named standard access control list (ACL).
acl-num
Filters incoming packets using a numbered ACL.
ipv6 ipv6-acl-name
Filters incoming packets using a named IPv6 ACL.
view mib-view
Associates a view to the members of the community string. Enter up to 32 alphanumeric characters.
Modes

Global configuration mode

Usage Guidelines

The view mib-view parameter allows you to associate a view to the members of this community string. If no view is specified, access to the full MIB is granted. The view that you want must exist before you can associate it to a community string.

You can set just one access type, either read-only (ro) or read/write (rw) for a single SNMP community instead of setting both access types. The read/write access supersedes read-only configuration and if read/write is configured for a specified community after read only, the running configuration file only saves the rw configuration line.

If you issue the no snmp-server community public ro command and then enter the write memory command to save the configuration, the read-only "public" community string is removed and will have no SNMP access. If for some reason the device is brought down and then brought up, the no snmp-server community public ro command is restored in the system and the read-only "public" community string has no SNMP access.

The no form of the command removes an SNMP community string.

Examples

The following example configures an SNMP community string with read-only access.

device# configure terminal
device(config)# snmp-server community private ro

The following example configures and applies an ACL to filter SNMP packets.

device# configure terminal
device(config)# ip access-list standard 25 
device(config-std-ipacl-25)# deny host 10.157.22.98 log
device(config-std-ipacl-25)# deny 10.157.23.0 0.0.0.255 log
device(config-std-ipacl-25)# deny 10.157.24.0 0.0.0.255 log 
device(config-std-ipacl-25)# permit any
device(config-std-ipacl-25)# exit
device(config)# ip access-list standard 30 
device(config-std-ipacl-30)# deny 10.157.25.0 0.0.0.255 log
device(config-std-ipacl-30)# deny 10.157.26.0/24 log
device(config-std-ipacl-30)# permit any
device(config-std-ipacl-30)# exit
device(config)# snmp-server community public ro 25 
device(config)# snmp-server community private rw 30
device(config)# write memory 

The following example associates a view to the members of a community string.

device# configure terminal
device(config)# snmp-server community private rw view view1