Port Security Violation Modes – Detailed Explanation
1. What are Violation Modes?
Violation modes are switch port security settings that determine how a switch will respond if an unauthorized device (or MAC address) attempts to access a secure port.
Role: To protect network access at the edge by controlling which MAC addresses are allowed on specific switch ports.
2. How Switches Respond to Security Violations
When a port with port security receives a frame from a MAC address not allowed by the configured security policy, the switch reacts based on its configured violation mode.
3. Protect Mode
- Frames from unauthorized MAC addresses are silently dropped (no alert).
- No notification, log messages, or SNMP traps.
- The port remains up and continues to forward allowed traffic.
4. Restrict Mode
- Frames from unauthorized MACs are dropped (like protect mode).
- Violation is logged: The switch generates SNMP traps and syslog messages.
- The port stays up for authorized traffic.
5. Shutdown Mode (Default)
- The port is placed into error-disabled (err-disabled) state—shut down.
- Logs the violation and sends SNMP traps.
- All traffic stops until the port is manually or automatically recovered.
6. Comparison of Violation Modes
Mode | Action on Violation | Logging/Notification | Port Status |
---|---|---|---|
Protect | Drop violating frames (silent) | No | Remains up |
Restrict | Drop violating frames | Yes (logs/traps) | Remains up |
Shutdown | Interface err-disabled (shutdown) | Yes (logs/traps) | Down (err-disabled) |
7. When to Use Each Mode
- Protect: Minimal disruption, no logging; low-security user zones.
- Restrict: Logging/monitoring needed, but port must remain up.
- Shutdown: Strict security zones (finance, DMZ, executives) – disables port until reviewed.
8. Configuring Violation Modes
interface FastEthernet0/1 switchport port-security switchport port-security violation protect ! or restrict/shutdown
Default: If not specified, mode is shutdown.
9. Detection and Logging
- Violation triggers:
- Number of learned MAC addresses exceeds the configured maximum.
- Unknown MAC sends traffic to the port.
- Monitor violations:
show port-security interface FastEthernet0/1
show port-security address
show logging | include SEC
- Restrict/Shutdown: Generate SNMP traps and logs. Protect: No logging.
10. Recovery from Shutdown Mode
- Manual Recovery:
interface FastEthernet0/1 shutdown no shutdown
- Automatic Recovery:
errdisable recovery cause psecure-violation errdisable recovery interval 300 ! (seconds)
11. Best Practices for Violation Modes
- Use protect where service continuity is critical and logging is not required.
- Use restrict where you want logs but not port disruption.
- Use shutdown in sensitive areas or where investigation is mandatory.
- Always monitor logs and SNMP traps for security events.
- Document and label security settings for easier management.
12. Troubleshooting Violation Issues
Symptom | Diagnosis | Solution |
---|---|---|
Port is down (err-disabled) | Likely shutdown mode violation | shutdown/no shutdown, or auto recovery |
Frames dropped but no log/trap | Mode is protect | Change to restrict for logging |
Many violation logs, port still up | Mode is restrict, not shutdown | Review allowed MACs/network changes |
Frequent port security violations | Allowed MAC addresses may be outdated | Update or increase maximum as needed |
Example Scenario:
Secure a user port to allow only one MAC address; use restrict mode to log any violations but keep the port up.
Secure a user port to allow only one MAC address; use restrict mode to log any violations but keep the port up.
interface FastEthernet0/2 switchport mode access switchport port-security switchport port-security maximum 1 switchport port-security violation restrict switchport port-security mac-address stickyIf a device with a new MAC connects, frames are dropped and a log message is generated, but the port remains up for the allowed MAC.
Key Points and Exam Tips
Key Point | Explanation |
---|---|
Protect | Silent drop, no logs, port stays up |
Restrict | Drop + log/trap, port stays up |
Shutdown | Drop + log/trap, port is err-disabled (down) |
Default Mode | Shutdown (unless changed) |
When to Use | Protect/Restrict: User ports; Shutdown: High-security/DMZ/finance |
Monitoring | show port-security interface, SNMP/logs for restrict/shutdown |
Recovery | Manual (sh/no sh) or auto with errdisable recovery |
When and Where to Use Each Mode:
Protect/Restrict: General user ports, labs, or environments where uptime is important but monitoring is needed.
Shutdown: Finance, executive, DMZ, or any sensitive port—immediately disables access on any violation.
Protect/Restrict: General user ports, labs, or environments where uptime is important but monitoring is needed.
Shutdown: Finance, executive, DMZ, or any sensitive port—immediately disables access on any violation.