snmp-server community
To set the community access string (password) that permits access to SNMP commands (v1 and v2), use the snmp-server community Global Configuration mode command. This is used for SNMP commands, such as GETs and SETs.
This command configures both SNMP v1 and v2.
To remove the specified community string, use the no form of this command.
Syntax
snmp-server community community-string [ro | rw | su] [ip-address | ipv6-address] [mask mask | prefix prefix-length] [view view-name] [type {router | }]
no snmp-server community community-string [ip-address] [type {router | oob}]
Parameters
-
community-string—Define the password that permits access to the SNMP protocol. (Range: 1–20 characters).
-
ro—(Optional) Specifies read-only access (default)
-
rw—(Optional) Specifies read-write access
-
su—(Optional) Specifies SNMP administrator access
-
ip-address—(Optional) Management station IP address. The default is all IP addresses. This can be an IPv4 address, IPv6 or IPv6z address.
-
mask—(Optional) Specifies the mask of the IPv4 address. This is not a network mask, but rather a mask that defines which bits of the packet’s source address are compared to the configured IP address. If unspecified, it defaults to 255.255.255.255. The command returns an error if the mask is specified without an IPv4 address.
-
prefix-length—(Optional) Specifies the number of bits that comprise the IPv4 address prefix. If unspecified, it defaults to 32. The command returns an error if the prefix-length is specified without an IPv4 address.
-
view view-name—(Optional) Specifies the name of a view configured using the command snmp-server view (no specific order of the command configurations is imposed on the user). The view defines the objects available to the community. It is not relevant for su, which has access to the whole MIB. If unspecified, all the objects, except the community-table and SNMPv3 user and access tables , are available. (Range: 1–30 characters)
-
type router—(Optional) Indicates whether the IP address is on the out-of-band or in-band network.
Default Configuration
No community is defined
Command Mode
Global Configuration mode
User Guidelines
The logical key of the command is the pair (community, ip-address). If ip-address is omitted, the key is (community, All-IPs). This means that there cannot be two commands with the same community, ip address pair.
The view-name is used to restrict the access rights of a community string. When a view-name is specified, the software:
-
Generates an internal security-name.
-
Maps the internal security-name for SNMPv1 and SNMPv2 security models to an internal group-name.
-
Maps the internal group-name for SNMPv1 and SNMPv2 security models to view-name (read-view and notify-view always, and for rw for write-view also),
Example
Defines a password for administrator access to the management station at IP address 1.1.1.121 and mask 255.0.0.0.
switchxxxxxx(config)# snmp-server community abcd su 1.1.1.121 mask 255.0.0.0