Home Blog Certs Knowledge Base About

Cisco Switch Security

Cisco IOS Layer 2 security cheat sheet: Port Security, Storm Control, DHCP Snooping, IP Source Guard, Dynamic ARP Inspection, and PoE. These features protect the switched network from MAC flooding, DHCP starvation, ARP spoofing, and unauthorized devices.

Port Security

Limits the number of MAC addresses allowed on a port and takes action when the limit is exceeded.

Port Security Configuration
CommandDescription
switchport mode accessPort must be in access mode for port-security
switchport port-securityEnable port-security on interface
switchport port-security maximum 5Allow up to 5 MAC addresses (default: 1)
switchport port-security mac-address stickyLearn MAC addresses dynamically and keep them on reload
switchport port-security violation shutdownShut port when limit exceeded (default action; other: protect, restrict)
switchport port-security aging time 2Auto-remove dynamically learned MACs after 2 minutes
switchport port-security aging type absoluteRemove MAC after aging time regardless of activity
switchport port-security aging type inactivityRemove MAC only if inactive for aging time
mls rate-limit layer2 port-security 100 10Rate-limit frames from attacker in protect/restrict mode
errdisable recovery cause psecure-violationAuto-recover ports shut by port-security violation
clear port-security stickyClear learned sticky MAC addresses

IP phone + PC on the same port:

Voice + Data VLAN with Port Security
CommandDescription
switchport port-security maximum 1 vlan accessAllow 1 MAC in the data VLAN (for PC)
switchport port-security maximum 1 vlan voiceAllow 1 MAC in the voice VLAN (for IP phone)
switchport port-security mac-address <mac> vlan voiceStatically allow the phone's MAC in voice VLAN
switchport port-security mac-address <mac> vlan accessStatically allow the PC's MAC in data VLAN
Port Security Diagnostics
CommandDescription
show port-securityGlobal port-security status
show port-security int fa0/1Per-interface port-security status
show port-security addressMAC addresses protected by port-security

Storm Control

Limit broadcast, multicast, or unicast flooding on a port.

Storm Control Configuration
CommandDescription
storm-control broadcast level 50 30Rising threshold 50%, falling 30% for broadcast
storm-control multicast level pps 30k 20kMulticast limit: 30k pps rising, 20k falling
storm-control unicast level bps 30mUnicast limit: 30 Mbps
storm-control action shutdownShut port when threshold exceeded (alt: trap)
show storm-control [broadcast|multicast|unicast]Storm control statistics

DHCP Snooping

Validates DHCP messages by distinguishing trusted (server-side) and untrusted (client-side) ports. Also builds the binding table used by IP Source Guard and DAI.

DHCP Snooping Configuration
CommandDescription
ip dhcp snoopingEnable DHCP snooping globally
ip dhcp snooping vlan 1Enable for VLAN 1 (configure per each VLAN)
ip dhcp snooping trustMark interface as trusted (uplink to DHCP server)
ip dhcp snooping limit rate 10Max 10 DHCP requests/second per port (anti-starvation)
no ip dhcp snooping verify mac-addressDisable MAC verification check (enabled by default)
ip dhcp relay information trustedTrust DHCP relay info on SVI (for external DHCP servers)
ip dhcp relay information trust-allTrust relay info on all SVIs
ip dhcp snooping binding <mac> vlan <id> <ip> interface <if> expiry <sec>Add static entry to DHCP snooping binding table
DHCP Snooping Diagnostics
CommandDescription
show ip dhcp snoopingSnooping settings and trusted ports
show ip dhcp snooping bindingIP–MAC–VLAN–interface binding table
show ip dhcp snooping statisticsDrop/forward counters

IP Source Guard

Prevents IP spoofing by verifying source IPs against the DHCP Snooping binding table.

Requires DHCP Snooping to be enabled first.

IP Source Guard Configuration
CommandDescription
ip verify source vlan dhcp-snoopingEnable IP Source Guard on interface
ip source binding 00:E0:F7:EC:D0:10 vlan 1 192.168.1.1 interface fa0/4Manual binding for devices with static IPs (not in DHCP snooping table)
show ip verify sourceIP Source Guard status per interface
show ip source bindingManual IP–MAC binding entries

Dynamic ARP Inspection (DAI)

Validates ARP packets against the DHCP Snooping binding table to prevent ARP spoofing / man-in-the-middle attacks.

Requires DHCP Snooping to be enabled first.

DAI Configuration
CommandDescription
ip arp inspection vlan 1Enable DAI for VLAN 1 (configure per each VLAN)
ip arp inspection trustMark interface as trusted (uplinks between switches)
ip arp inspection limit rate 2Max 2 ARP requests/second on interface
errdisable recovery cause arp-inspection interval 600Auto-recover DAI-blocked ports after 600 s

Static ARP ACL for devices with static IPs (e.g., default gateway):

ARP ACL for Static Devices
CommandDescription
arp access-list ARP-EXCEPTIONSCreate ARP ACL
permit ip host 192.168.1.1 mac host 00:E0:F7:EC:D0:10Bind gateway IP to its real MAC — rejects ARP spoofing attempts
ip arp inspection filter ARP-EXCEPTIONS vlan 1Apply ARP ACL to VLAN
show ip arp inspectionDAI status and counters
show ip arp inspection interfaceWhich interfaces have DAI enabled

PoE — Power over Ethernet

PoE IEEE Classes
ClassMax PSE outputNote
Class 015.4 WDefault class (unclassified devices)
Class 14 WOptional — low-power devices
Class 27 WOptional
Class 315.4 WOptional — standard 802.3af devices
Class 451 W802.3at (PoE+) only — not available on 802.3af switches
PoE Configuration
CommandDescription
power inline autoAuto-detect and power connected PD device
power inline neverDisable PoE on interface
power inline auto max <milli-watts>Enable PoE with max wattage cap
show power inlinePoE status and remaining wattage per port

Err-Disabled Recovery

Err-Disabled Port Recovery
CommandDescription
errdisable recovery cause allAuto-recover ports for all err-disable causes
errdisable recovery interval 300Recovery timer (default: 300 s)
show interface fa0/1 statusCheck if port is in err-disabled state
show errdisable recoveryRecovery timers per cause
show errdisable detectCauses that can trigger err-disabled

To manually recover: resolve the root cause → shutdownno shutdown.


Cisco IOS Command Reference | Switch Security