Switchport Port Security
Port Security restricts the number of stations that are allowed to access a switch port.
Define allowed hosts
Each time a host attempts to send a frame, the source MAC address is added to the list of secure MACs. This list of secure MAC addresses has a limited size, and it can be configured with these types of secure MAC addresses:
Static: manually configured. Will appear in the running config.
Dynamic: learned from the source MAC of the frames that enter the port. They are not part of the config and will be lost on reload
Sticky: When enabled, it converts dynamic addresses into static sticky addresses so they will appear in the running config.
. Static sticky addresses can also be added using:
Enable port-security
To enable port security, the port must be statically set to access or trunk:
To enable port security, use:
By default, only 1 mac address will be allowed on this interface. You can modify the number of allowed mac addresses, using:
On trunk ports, the maximum value can be set per vlan:
if VLAN-LIST is missing, then a maximum for each vlan is set.
Security Violation
A security violation occurs when the maximum number of secure MAC addresses have been added to the list and a new station attempts to send a frame, or when an address learned or configured on one secure interface attempts to send a frame on another secure interface in the same VLAN. The default security violation mode is “shutdown” but this can be changed with:
protect: Frames sent by hosts that are not in the secure list are dropped. No notification occurs
restrict: Just like protect, but also sends a SNMP trap, a syslog message is logged and a violation counter increments
shutdown: The interface is errdisabled. The switch sends a SNMP trap, a syslog message is logged and a violation counter increments
shutdown vlan: Only the offending vlan is errdisabled. The switch sends a SNMP trap, a syslog message is logged and a violation counter increments
Recovery from the errdisabled mode can be manually (shut/no shut) or automatically:
Clearing allowed hosts list
Manual
The list of secure MAC addresses can be cleared manually, using:
Auto
The addresses in the list of secure MAC addresses can be aged out if you set:
The aging can be absolute (the address will be aged out after the configured interval) or relative to inactivity (the address will be aged out after an interval of inactivity equal to the configured value).
Normally, the aging process happens only for dynamic addresses. It cannot be used for sticky addresses, but it can be used for static addresses, using:
Verification
To verify port-security status, you can use:
Last updated