Week 10 · Lab

LAB: Layer 2 Security

A switch that trusts every plugged-in device is a switch that lets strangers in the door. In this lab you turn port security on an access port with sticky MAC learning, trigger a violation, and recover the port from err-disable — then you enable DHCP snooping and watch a client’s lease get recorded in the binding table. These are the exact features that appear on the CCNA security labs.

CCNA 200-301 Domain 5.0 Security Fundamentals Verified 2026-10-11
Learning objectives
Part 1

Overview and goal

A single switch builds a small LAN. On the user port (Fa0/1) you will enforce one allowed MAC address, learned sticky, and watch a second device trip the violation — first in restrict mode, then with the default shutdown, so you see the err-disable state and its recovery. Then you will add DHCP snooping: the client (or a router acting as the DHCP server on the port you trust) does a normal DORA exchange, and you inspect the resulting binding table. Along the way you practise the verification commands that every Layer 2 security question assumes.

Definition — this lab’s terms Port security limits which MAC addresses may use an access port. Sticky learning writes the learned MAC into the running configuration. Err-disable is the port state forced on by a shutdown-mode violation. DHCP snooping validates DHCP offers/acks against trusted ports and builds a binding table.
In this lesson · select a part to jump

Key ideas & exam traps · select one

Part 2

Topology

S1 (switch) PC1 Fa0/1 PC2 (rogue) Fa0/2 DHCP server Gi0/1 (trusted) DHCP offer ok
PC1 is the trusted workstation on Fa0/1; PC2 is the device later used to try “wrong MAC” attacks. The DHCP server sits up the trusted uplink Gi0/1.
Part 3

Setup and addressing

DevicePortRoleIP / notes
S1Fa0/1User access portPort security + sticky
S1Fa0/2Spare portUsed to test violation behaviour
S1Gi0/1Uplink / DHCP serverTrusted for DHCP snooping
PC1—DHCP client192.168.10.50 (from server)
DHCP Server—Address server192.168.10.10, pool 192.168.10.0/24

On an 2960-class switch, this shape works out of the box: the defaults are switchport port-security maximum 1 and violation mode shutdown.

Reference table · select a row

Part 4

Step 1 — Port security with sticky MAC

Configure the access port with port security, cap it at one address, and let it learn PC1’s MAC as a sticky entry:

S1(config)# interface fastethernet0/1
S1(config-if)# switchport mode access
S1(config-if)# switchport port-security
S1(config-if)# switchport port-security maximum 1
S1(config-if)# switchport port-security mac-address sticky
S1(config-if)# switchport port-security violation shutdown
S1(config-if)# end
S1# show port-security interface fastethernet0/1
Port Security              : Enabled
Port Status                : Secure-up
Violation Mode             : Shutdown
Maximum MAC Addresses      : 1
Total MAC Addresses        : 1
Configured MAC Addresses   : 0
Sticky MAC Addresses       : 1
Last Source Address:Vlan   : 0050.7966.6800:10
Why sticky? Hard-coding a MAC (mac-address 0050.7966.6800) is precise but fragile — every legitimate hardware swap needs a config edit. Sticky records whatever device is plugged in at the time, so setup is one command and the address lands in the running config. Remember to copy running-config startup-config or the sticky entry evaporates on reboot.
Part 5

Step 2 — Trigger a violation

Now unplug PC1, plug a different device (PC2) into Fa0/1, and generate traffic. Because PC2’s MAC is not the learned one and the maximum is 1, a violation fires. With violation mode shutdown, the interface goes err-disabled:

S1# show interfaces status
Port      Name   Status       Vlan    Duplex Speed Type
Fa0/1            err-disabled 10      auto   auto  ...
Exam tip — reading the state shutdown mode puts the port into err-disable (shown as err-disabled) and blocks all traffic — not just the rogue MAC. The lighter modes restrict (drops + logs + counter) and protect (silently drops) leave the port up. The exam will hand you one of the three symptoms and ask you to name the mode.

Experiment worth doing in the simulator: repeat with violation restrict to watch the SecurityViolation counter rise while the port stays up, and protect to see the silent drop. You will never forget the three after you have seen each happen.

Part 6

Step 3 — Recover from err-disable

err-disabled ports do not self-heal by default. Recovery is either manual — bounce the port — or automatic, after a timer, using the specific err-disable cause:

! Manual recovery (works immediately)
S1(config)# interface fastethernet0/1
S1(config-if)# shutdown
S1(config-if)# no shutdown
S1(config-if)# exit

! Or automatic recovery for port-security violations
S1(config)# errdisable recovery cause psecure-violation
S1(config)# errdisable recovery interval 300
S1(config)# end
S1# show errdisable detect | include psecure
Warning Automatic recovery is convenient, but the switch re-arms the same policy each time the port comes up. If the rogue device is still attached, the port will wander straight back into err-disable. Recovery treats the symptom; removing the attacker treats the cause.
Part 7

Step 4 — DHCP snooping

DHCP snooping makes the switch distrust client ports for DHCP offers/acks. Enable it globally and for VLAN 10, then mark the uplink to the real DHCP server as trusted:

S1(config)# ip dhcp snooping
S1(config)# ip dhcp snooping vlan 10
S1(config)# interface gigabitethernet0/1
S1(config-if)# ip dhcp snooping trust
S1(config-if)# exit
S1(config)# interface fastethernet0/1
S1(config-if)# ip dhcp snooping limit rate 10
S1(config-if)# end

Only the port facing the server is trusted now. Every untrusted port (Fa0/1, Fa0/2 …) can send DHCP discover/request, but any DHCP offer or ack arriving from it is dropped — which is precisely how a rogue DHCP server on the desk is neutralised. ip dhcp snooping limit rate 10 caps the DHCP message rate to stop a flood of requests from saturating the CPU.

Part 8

Step 5 — Verify the binding and filtering

Restart the client interface (or renew its lease) so a fresh DORA exchange happens, then inspect the results:

S1# show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
10
Insertion of option 82 is enabled
Interface                    Trusted    Rate limit (pps)
----------------------------- ---------- ----------------
GigabitEthernet0/1           yes         unlimited
FastEthernet0/1              no          10

S1# show ip dhcp snooping binding
MacAddress          IpAddress        Lease(sec)  Type           VLAN  Interface
------------------  ---------------  ----------  -------------  ----  -----------------
00:50:79:66:68:00   192.168.10.50    86215       dhcp-snooping  10    FastEthernet0/1
S1# show port-security address
               Secure Mac Address Table
Vlan    Mac Address     Type        Ports
----    --------------- ----------- -----
  10    0050.7966.6800  SecureSticky  Fa0/1

Two proofs in one screen: the DHCP binding table links PC1’s MAC to its leased IP on Fa0/1 — ready to be consumed by DAI in a larger design — and the port-security table shows the sticky MAC with type SecureSticky.

Note If the binding table stays empty, the trusted port is probably pointing the wrong way. Trust must face the legitimate server; if Gi0/1 does not actually host (or transit to) the DHCP server, offers get blocked as if they were attacks, and the client never receives an address.
Part 9

Troubleshooting guide

Key terms

The vocabulary you need

Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.

Key terms · select a term

Part 10 · Your turn

Review

Check what you have learned with these review questions.

Review · 5 questions

Sources

Sources & references

  1. Cisco. CCNA (200-301) Exam Topics. cisco.com.
  2. IETF. Request for Comments (RFCs). rfc-editor.org.
  3. IANA. Internet Assigned Numbers Authority registries. iana.org.

Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.