Port security and DHCP snooping
Layer 2 attacks (CAM overflow, rogue DHCP, ARP spoofing) bypass everything above. Port Security limits which MACs may appear on a port; DHCP Snooping permits DHCP responses only from trusted ports; Dynamic ARP Inspection rejects forged ARP.
What you'll learn
- Configure port security with sticky MAC learning.
- Enable DHCP snooping and mark trusted ports.
- Explain how DAI builds on the snooping binding table.
Port Security — limiting MACs per port
By default, a switch port accepts frames from any source MAC. Port Security restricts the count and (optionally) the specific MACs allowed. A violation can shut the port (default — err-disable it and increment the violation counter), restrict it (drop the violating frames, increment the Security Violation Count and send a log/SNMP notification, while the port keeps forwarding for its learned secure MACs), or protect it (drop the violating frames silently — no counter increment and no log).
The maximum is counted per PORT, across every VLAN on it — an IP phone with a PC daisy-chained behind it is two source MACs on one port even though voice and data ride different VLANs. With maximum 1 the second device is a violation; raise it to 2 (or 3 if the phone also sources a MAC on the data VLAN) before the move.
Sticky MACs are written into the RUNNING configuration only. Until you copy running-config startup-config, a reload loses them and the port relearns whatever is plugged in first.
Switch(config)# interface Fa0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport port-security
Switch(config-if)# switchport port-security maximum 2
Switch(config-if)# switchport port-security mac-address sticky
Switch(config-if)# switchport port-security violation shutdownReading show port-security
The summary gives one row per secure port: the per-port maximum (MaxSecureAddr), how many secure MACs it holds now (CurrentAddr), the violation counter, and the violation action. A port already at CurrentAddr = MaxSecureAddr treats the next new source MAC as a violation — with the action Shutdown, that port is err-disabled. Use show port-security interface Fa0/6 for one port's detail.
The two Total lines under the table count addresses across the whole switch, not per port, so they rarely matter when you are chasing one jack.
SW1# show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
---------------------------------------------------------------------------
Fa0/5 1 1 0 Shutdown
Fa0/6 1 1 0 Shutdown
---------------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 819212 more sections in this chapter, plus a 4-question quiz and a hands-on lab.
Modules 2–8 are part of the Course & Lab Pass and All-Access Max — start with a free account
You can see the title, summary, learning objectives and the opening sections. The rest of this chapter, like all of modules 2–8, comes with the Course & Lab Pass and All-Access Max. A free account opens Module 1: How Networks Work end-to-end and saves your labs — start there, no card required.
- Read every chapter in Module 1 — How Networks Work
- Save labs of up to 5 devices
- Save up to 3 topologies
- See the full course syllabus + chapter titles
Free account · no card required · compare plans any time