🔐 Cisco IOS Port Security Configuration Guide¶
Port Security is a Layer 2 feature that restricts input to an interface by limiting and managing the MAC addresses allowed to access the port. It helps prevent unauthorized devices from connecting to the network.
🧠 What Port Security Does¶
- Limits the number of MAC addresses per port
- Allows static or dynamically learned MAC addresses
- Supports actions on violation:
protect,restrict, orshutdown - Commonly used on access ports to secure edge devices
🛠️ Step-by-Step Configuration¶
1. Enter Global Configuration Mode¶
2. Configure the Interface¶
3. Enable Port Security¶
4. Set Maximum MAC Addresses (default is 1)¶
5. Define Allowed MAC Addresses (optional)¶
Or allow dynamic learning:
6. Set Violation Action¶
Options:
- protect: drops packets from unknown MACs
- restrict: drops packets and logs the violation
- shutdown: puts the port in err-disabled state (default)
7. Exit and Save¶
🔍 Verification Commands¶
Show Port Security Status¶
Show All Port Security Info¶
Show Sticky MAC Addresses¶
🧯 Recover from Violation (Err-Disabled)¶
If a port is shut down due to a violation:
To prevent future lockouts, consider using restrict or protect instead of shutdown.
✅ Best Practices¶
- Use
stickyMACs for dynamic but persistent learning - Limit MACs to 1 per port for end-user devices
- Monitor violations with
restrictbefore enforcingshutdown - Combine with other features like DHCP snooping and dynamic ARP inspection for layered security