zNetLaB › Guided labs › Security
Sticky port security 14 — learn once, shut on a stranger
Security Intermediate 3 devices 5 checked tasks 100 points Plan lab
Scenario — the Printers desk in Ranchi is a fixed PC. Lock Fa0/1 to 2 MAC addresses learned sticky (written into the running configuration, so it survives a save), make a violation shut the port, and let the switch recover the port on its own after the cause is gone — errdisable recovery for the port-security cause. 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
the Printers desk in Ranchi is a fixed PC. Lock Fa0/1 to 2 MAC addresses learned sticky (written into the running configuration, so it survives a save), make a violation shut the port, and let the switch recover the port on its own after the cause is gone — errdisable recovery for the port-security cause.
Your role: a security engineer. Level: Intermediate Done when: all 5 goals show as passed (100 points).
Network status
Devices: 1 switch, 2 PCs, cabled as drawn. No Layer 1 or Layer 2 faults: every link is connected and up. SW-Ranchi starts with and VLAN 23 already configured. Printers-PC is a host with 10.33.0.11/24. Neighbour is a host with 10.33.0.12/24.
Known problems
The network worked and now does not: the scenario above says what users report. The cause is a configuration fault, not a cable. Find it with show commands (interfaces, routes, neighbours, running-config) before you change anything; fix only what is wrong.
Goals
Fa0/1 allows exactly 2 MAC addresses (25 pts) Learned addresses are sticky (25 pts) A violation shuts the port down (20 pts) Err-disabled ports recover automatically (20 pts) The desk still reaches its neighbour (10 pts)
The activity, in order
Fa0/1 allows exactly 2 MAC addresses Turn on port security on FastEthernet0/1 of SW-Ranchi 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 Learned addresses are sticky The configuration of SW-Ranchi must contain the line: interface FastEthernet0/1[^!]*port-security mac-address sticky. 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 A violation shuts the port down The configuration of SW-Ranchi must contain the line: interface FastEthernet0/1[^!]*port-security violation shutdown|interface FastEthernet0/1(?![^!]*violation)[^!]*port-security. 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 Err-disabled ports recover automatically The configuration of SW-Ranchi 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 The desk still reaches its neighbour From Printers-PC, ping 10.33.0.12. 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.33.0.12
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: Forgetting that sticky addresses are lost on reload unless saved Common mistake: Setting the maximum below what the desk really needs Common mistake: Shutdown mode without recovery
Why this matters
Sticky learning turns the first MAC addresses seen into permanent configuration. A violation in shutdown mode err-disables the port, so someone has to notice — and errdisable recovery brings it back after the timer so a typo does not mean a site visit.
What you will be able to do
Configure sticky MAC learning and a maximum
Choose the violation mode
Enable errdisable recovery
The network
Catalyst 2960-24TT, PC — 3 devices in all, already cabled.
Fa0/1 Fa0 Fa0/2 Fa0 SW-Ranchi Printers-PC 10.33.0.11/24 Neighbour 10.33.0.12/24 Drawn from this lab: devices, cables, ports and the addresses already set.
Device Model Address already set
SW-Ranchi Catalyst 2960-24TT configure it
Printers-PC PC 10.33.0.11 / 255.255.255.0
Neighbour PC 10.33.0.12 / 255.255.255.0
Cabling
SW-Ranchi Fa0/1 ↔ Printers-PC Fa0
SW-Ranchi Fa0/2 ↔ Neighbour Fa0
What is configured at the start
These are already configured when the lab opens — including, where this is a troubleshooting lab, the fault itself:
SW-Ranchi vlan 23
exit
interface fa0/1
switchport mode access
switchport access vlan 23
exit
interface fa0/2
switchport mode access
switchport access vlan 23
exit
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 Fa0/1 allows exactly 2 MAC addresses 25 On SW-Ranchi: show port-security interface Fa0/1 — maximum 2.
2 Learned addresses are sticky 25 On SW-Ranchi: show running-config contains the line(s) matching interface FastEthernet0/1 … port-security mac-address sticky.
3 A violation shuts the port down 20 On SW-Ranchi: show running-config contains the line(s) matching interface FastEthernet0/1 … port-security violation shutdown|interface FastEthernet0/1(?! … violation) … port-security.
4 Err-disabled ports recover automatically 20 On SW-Ranchi: show running-config contains the line(s) matching errdisable recovery cause psecure-violation.
5 The desk still reaches its neighbour 10 On Printers-PC: ping 10.33.0.12 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
Forgetting that sticky addresses are lost on reload unless saved
Setting the maximum below what the desk really needs
Shutdown mode without recovery
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-Ranchi interface fa0/1
switchport port-security
switchport port-security maximum 2
switchport port-security mac-address sticky
switchport port-security violation shutdown
exit
errdisable recovery cause psecure-violation
Where this is examined
CCNA 5.0 port security; Security+ 3.2.
This lab practises these topics in the zNetLaB certification courses:
Port security, DHCP snooping, DAI — CCNA · Security Fundamentals
ACLs, ZBFW, 802.1X, MACsec, wireless security — CCNP Enterprise · ENCOR · Security
Access control: ACLs, AAA, remote access and VPNs — CompTIA Network+ · Network Security
Network segmentation, DMZ and firewalls — CompTIA Security+ · Security Architecture
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.