zNetLaB › Guided labs › Security
Port security — stop a MAC-flooding attack
Security Intermediate 4 devices 5 checked tasks 100 points Plan lab
A switch’s address table is finite. An attacker who floods it with thousands of fake source MACs turns the switch into a hub and can read other people’s traffic. Limit each access port to a handful of addresses, make a violation shut the port, and let the port come back by itself after a while. You build it in a browser, type real commands at each device, and every task below is
checked against the running configuration — so you find out it is wrong before anybody else does.
Open this lab in the simulator
The simulator runs in your browser with nothing to install. This lab is part of the full simulator: open it free for 7 days with a new account, then with a plan. It needs an account, which keeps your progress.
The scenario
A switch’s address table is finite. An attacker who floods it with thousands of fake source MACs turns the switch into a hub and can read other people’s traffic. Limit each access port to a handful of addresses, make a violation shut the port, and let the port come back by itself after a while.
Your role: a security engineer. Level: Intermediate Done when: all 5 goals show as passed (100 points).
Network status
Devices: 1 switch, 2 PCs, 1 server, cabled as drawn. No Layer 1 or Layer 2 faults: every link is connected and up. Staff-PC is a host with 10.50.0.11/24. Attacker is a host with 10.50.0.66/24. File-Server is a host with 10.50.0.5/24. SW-Access starts with an empty configuration.
Known problems
None: nothing is misconfigured. The network is simply not finished: what the goals list is what you have to build or secure.
Goals
Both user ports are access ports with port security on (25 pts) Each user port allows at most 2 MAC addresses (20 pts) A violation shuts the port down (shutdown mode) (20 pts) Error-disabled ports recover by themselves (port-security cause, 300 s) (20 pts) Staff-PC still reaches the file server (15 pts)
The activity, in order
Both user ports are access ports with port security on Turn on port security on FastEthernet0/1 of SW-Access with a maximum of undefined MAC address(es). Turn on port security on FastEthernet0/2 of SW-Access with a maximum of undefined MAC address(es).Why: Port security stops somebody plugging an extra switch or laptop into a wall port. Verify with: show port-security Each user port allows at most 2 MAC addresses Turn on port security on FastEthernet0/1 of SW-Access with a maximum of 2 MAC address(es). Turn on port security on FastEthernet0/2 of SW-Access with a maximum of 2 MAC address(es).Why: Port security stops somebody plugging an extra switch or laptop into a wall port. Verify with: show port-security A violation shuts the port down (shutdown mode) The configuration of SW-Access must contain the line: interface FastEthernet0/2[^!]*switchport port-security violation shutdown|interface FastEthernet0/2[^!]*switchport port-security(?![^!]*violation). Type it in the right mode (global, interface or line) and check it appears.Why: This is the task that checks your configuration directly: the line must really be there, not just look right. Verify with: show running-config Error-disabled ports recover by themselves (port-security cause, 300 s) The configuration of SW-Access must contain the line: errdisable recovery cause psecure-violation. Type it in the right mode (global, interface or line) and check it appears.Why: This is the task that checks your configuration directly: the line must really be there, not just look right. Verify with: show running-config Staff-PC still reaches the file server From Staff-PC, ping 10.50.0.5. If it fails, walk the path hop by hop: gateway, then each router’s routing table, then the way back.Why: A ping needs a route in BOTH directions. This is the end-to-end proof that everything before it worked. Verify with: ping 10.50.0.5
Tips
Work in the order given: later goals depend on the earlier ones. After every change, run the verify command before moving on; do not guess. Stuck? Read the verify output first. It names the interface, neighbour or route that is wrong. Common mistake: A maximum of 1 on a port with an IP phone and a PC behind it Common mistake: Sticky MACs saved to the wrong place, or lost on reload Common mistake: Shutdown mode with no errdisable recovery — the port stays down until somebody notices
Why this matters
A switch’s MAC table is finite. Flood it with thousands of forged source addresses and the switch starts flooding frames out of every port like a hub — an attacker can then read other people’s traffic. Port security caps the addresses per port.
What you will be able to do
Limit the number of MAC addresses on an access port
Choose a violation mode and explain protect, restrict and shutdown
Configure automatic recovery of err-disabled ports
The network
Catalyst 2960-24TT, PC, Server — 4 devices in all, already cabled.
Fa0/1 Fa0 Fa0/2 Fa0 Fa0/24 Fa0 SW-Access Staff-PC 10.50.0.11/24 Attacker 10.50.0.66/24 File-Server 10.50.0.5/24 Drawn from this lab: devices, cables, ports and the addresses already set.
Device Model Address already set
SW-Access Catalyst 2960-24TT configure it
Staff-PC PC 10.50.0.11 / 255.255.255.0
Attacker PC 10.50.0.66 / 255.255.255.0
File-Server Server 10.50.0.5 / 255.255.255.0
Cabling
SW-Access Fa0/1 ↔ Staff-PC Fa0
SW-Access Fa0/2 ↔ Attacker Fa0
SW-Access Fa0/24 ↔ File-Server Fa0
What is configured at the start
Nothing is configured to start with beyond the addresses above: you build the configuration from a clean start.
Tasks, and how each one is checked
Every task is decided by reading the live network — a neighbour in FULL, a ping that succeeds, a line in the running configuration — not by looking for a keyword you typed. The same command shows you what the lab sees.
# Task Pts How to verify it yourself
1 Both user ports are access ports with port security on 25 On SW-Access: show port-security interface Fa0/1. and On SW-Access: show port-security interface Fa0/2.
2 Each user port allows at most 2 MAC addresses 20 On SW-Access: show port-security interface Fa0/1 — maximum 2. and On SW-Access: show port-security interface Fa0/2 — maximum 2.
3 A violation shuts the port down (shutdown mode) 20 On SW-Access: show running-config contains the line(s) matching interface FastEthernet0/2 … switchport port-security violation shutdown|interface FastEthernet0/2 … switchport port-security(?! … violation).
4 Error-disabled ports recover by themselves (port-security cause, 300 s) 20 On SW-Access: show running-config contains the line(s) matching errdisable recovery cause psecure-violation.
5 Staff-PC still reaches the file server 15 On Staff-PC: ping 10.50.0.5 must succeed.
Stuck? Ask the coach
Tell the coach what you see or what you tried. It gives you a hint, not the answer, the way a senior engineer would. Included with a free trial or any plan.
Ask the coach
Common mistakes
A maximum of 1 on a port with an IP phone and a PC behind it
Sticky MACs saved to the wrong place, or lost on reload
Shutdown mode with no errdisable recovery — the port stays down until somebody notices
Reference solution
Try it yourself first — the lab checks your work either way. This is one configuration that makes every task pass, device by device:
SW-Access interface range Fa0/1 - 2
switchport mode access
switchport port-security
switchport port-security maximum 2
switchport port-security violation shutdown
exit
errdisable recovery cause psecure-violation
errdisable recovery interval 300
Where this is examined
CCNA security fundamentals, CCNP SCOR (Layer 2), Security+ (MAC flooding), CEH (sniffing).
This lab practises these topics in the zNetLaB certification courses:
Port security, DHCP snooping, DAI — CCNA · Security Fundamentals
Attacks and their defences (spoofing, flooding, rogue devices) — CompTIA Network+ · Network Security
Network attacks: spoofing, flooding, rogue devices, VLAN hopping — CompTIA Security+ · Threats, Vulnerabilities and Mitigations
Infrastructure security: Layer 2 and the management plane — CCNP Security Core · Network Security
Layer-2 attacks: MAC flooding, VLAN hopping, STP takeover — Ethical Hacking (network level) · Network Attacks and Defences
Port security — Switching and VLAN Mastery · Securing the access layer
Related labs
Where to start
The lessons are open to everyone, all guided labs are listed by track, and
plans explains what is free and what is not.
CCNA®, CCNP® and Cisco® are trademarks of Cisco Systems, Inc. zNetLaB is not affiliated with or endorsed by Cisco.