Layer 2 Defense: Understanding Port Security
Port Security restricts a switch port to specific MAC addresses, preventing unauthorized devices from connecting and mitigating MAC flooding attacks.
What is Port Security?
Cisco **Port Security** is a Layer 2 security feature that limits and identifies MAC addresses of the systems allowed to access a port. If a port is configured as a secure port and the maximum number of secure MAC addresses is reached, any new MAC address detected will trigger a security violation. This effectively mitigates CAM table flooding attacks and prevents rogue devices.
Violation Modes
When a violation occurs, the switch can take one of three actions:
* **Protect:** Drops frames from unknown MACs. No syslog message is sent, and the violation counter doesn't increase. * **Restrict:** Drops frames from unknown MACs, generates a syslog message, and increments the violation counter. * **Shutdown (Default):** Disables the port entirely, putting it into an `err-disabled` state, sends a syslog message, and increments the counter.
Sticky MAC Addresses
Manually typing MAC addresses is tedious. You can use the **Sticky** feature, which allows the switch to dynamically learn MAC addresses and automatically save them into the running configuration.
* Command: `switchport port-security mac-address sticky`
If you save the configuration (`write memory`), these sticky addresses survive a reboot.
❓ Frequently Asked Questions
What is the default violation mode for Port Security?
The default violation mode is Shutdown, which puts the port into an err-disabled state.
What does a sticky MAC address do?
It dynamically learns the connected device's MAC address and adds it to the running configuration as a secure address.
How do you recover a port from err-disabled state?
You must issue a 'shutdown' command followed by a 'no shutdown' command on the interface, or configure errdisable recovery.