Security Commands
Use these M4500 CLI commands to configure port security (MAC locking) with dynamic, static, and sticky MAC limits and violation shutdown.
This section describes the commands you use to configure Port Security, which is also known as port MAC locking, allows you to secure the network by locking allowable MAC addresses on a given port. Packets with a matching source MAC address are forwarded normally, and all other packets are discards.
show port-security
This command displays the port-security settings for the port(s). If you do not use a parameter, the command displays the Port Security Administrative mode. Use the optional parameters to display the settings on a specific interface, port-channel, or on all interfaces.
| Format | show port-security [{<slot/port> | all | port-channel <portchannel-id>}] |
| Mode |
Privileged EXEC User EXEC |
Display Message
If you do not use the optional parameters slot/port, all, or port-channel <id>, then the command displays following information.
| Parameter | Definition |
|---|---|
| Administrative Mode | Port Locking mode for the entire system. The field displays if you do not support any parameters. |
For each interface, or for the interface you specify, the following information appears:
| Parameter | Definition |
|---|---|
| Admin Mode | Port Locking mode for the interface. |
| Dynamic Limit | Maximum dynamically allocated MAC addresses. |
| Static Limit | Maximum statically allocated MAC addresses. |
| Violation Trap Mode | Whether violation traps are enabled. |
| Violation Shutdown | Whether violation shutdown mode are enabled. |
| Sticky Mode | Whether sticky mode are enabled. |
Example: The following shows example CLI display output for the command.
(M4500-32C) #show port-security
Port Security Administration Mode: Disabled
(M4500-32C) #show port-security 0/1
Admin Dynamic Static Violation Violation Sticky
Intf Mode Limit Limit Trap Mode Shutdown Mode
------ ----------- -------- -------- ------------- ------------ --------
0/1 Disabled 600 20 Disabled Disabled Disabled
show port-security dynamic
This command displays the dynamically locked MAC address for the port.
| Format | show port-security dynamic {<slot/port> | port-channel <portchannel-id>} |
| Mode |
Privileged EXEC User EXEC |
Display Message
| Parameter | Definition |
|---|---|
| MAC AddressDynamically learned MAC Address | MAC Address of dynamically locked MAC |
| VLAN ID | VLAN ID on which the MAC address was learnt. |
| Number of Dynamic MAC addresses learned | The number of dynamic MAC addresses learned |
show port-security static
This command displays the statically locked MAC address for port.
| Format | show port-security static {<slot/port> | port-channel <portchannel-id>} |
| Mode |
Privileged EXEC User EXEC |
Display Message
| Parameter | Definition |
|---|---|
| Number of static MAC addresses configured | The number of static MAC addresses configured |
| Statically Configured MAC Address | The statically configured MAC address. |
| VLAN ID | The ID of the VLAN that includes the host with the specified MAC address. |
| Sticky | Indicates whether the static MAC address entry is added in sticky mode. |
Example: The following shows example CLI display output for the command.
(M4500-32C) #show port-security static 0/1
Number of static MAC addresses configured: 1
Statically configured MAC Address VLAN ID Sticky
--------------------------------- ------- ------
00:00:01:01:00:00 2 No
show port-security violation
This command displays the source MAC address of the last packet discarded on a locked port.
| Format | show port-security violation {<slot/port> | port-channel <portchannel-id>} |
| Mode |
Privileged EXEC User EXEC |
Display Message
| Parameter | Definition |
|---|---|
| Last Violation MAC AddressMAC Address | The source MAC Address of the last frame that was discarded at a locked port. |
| VLAN ID | The VLAN ID, if applicable, associated with the MAC address of the last frame that was discarded at a locked port. |
port-security
This command enables port locking at the system level (Global Config) or port level (Interface Config) on an interface, a range of interfaces.
| Default | Disabled |
| Format | port-security |
| Mode |
Global Config Interface Config |
no port-security
This command disables port locking for one or a range of ports (Interface Config) or all (Global Config) ports.
| Format | no port-security |
| Mode |
Global Config Interface Config |
port-security max-dynamic
This command sets the maximum number of dynamically locked MAC addresses allowed on a specific port.
| Default | 600 |
| Format | port-security max-dynamic <0-600> |
| Mode | Interface Config |
no port-security max-dynamic
This command resets the maximum number of dynamically locked MAC addresses allowed on a specific port to its default value.
| Format | no port-security max-dynamic |
| Mode | Interface Config |
port-security max-static
This command sets the maximum of statically locked MAC addresses allowed on a specific port.
| Default | 20 |
| Format | port-security max- static <0-20> |
| Mode | Interface Config |
no port-security max-static
This command resets the maximum number of statically locked MAC addresses allowed on a specific port to its default value.
| Format | no port-security max- static |
| Mode | Interface Config |
port-security mac-address
This command adds a MAC address to the list of statically locked MAC addresses
| Default | None |
| Format | port-security mac-address <mac-address> <vlan-id> |
| Mode | Interface Config |
no port-security mac-address
This command removes a MAC address from the list of statically locked MAC addresses.
| Format | no port-security mac-address <mac-address> <vlan-id> |
| Mode | Interface Config |
port-security mac-address move
This command converts dynamically locked MAC addresses to statically locked MAC addresses for an interface or a range of interfaces
| Default | None |
| Format | port-security mac-address move |
| Mode | Interface Config |
port-security mac-address sticky
This command enables sticky mode Port MAC Locking on a port. If accompanied by a MAC address and a VLAN id (for interface config mode only), it adds a sticky MAC address to the list of statically locked MAC addresses. These sticky addresses are converted back to dynamically locked addresses if sticky mode is disabled on the port. The Global command applies the “sticky” mode to all valid interfaces (physical and port-channel). There is no global sticky mode as such.
Sticky addresses that are dynamically learned will appear in show running-config as “port-security mac-address sticky <mac-address> <vid>” entries. This distinguishes them from the static entries.
| Default | None |
| Format | port-security mac-address sticky [<mac-address> <vlan-id>] |
| Mode |
Global Config Interface Config |
no port-security mac-address sticky
This command removes the sticky mode. The sticky MAC address can be deleted by using the command “no port-security mac-address <mac-address> <vlan-id>”.
| Format | no port-security mac-address sticky |
| Mode |
Global Config Interface Config |
Example: The following shows an example of the command.
(M4500-32C) (Config)#port-security mac-address sticky
(M4500-32C) (Interface 0/1)#port-security mac-address sticky
(M4500-32C) (Interface 0/1)#port-security mac-address sticky 00:00:00:00:00:01 2
port-security violation shutdown
This command configures the port violation shutdown mode. Once the violation happens, the interface will be shutdown
| Default | Disabled |
| Format | port-security violation shutdown |
| Mode | Interface Config |
no port-security violation
This command restores violation mode to the default value.
| Format | no port-security violation |
| Mode | Interface Config |