Instiq
Chapter 5 · Security Fundamentals·v1.0.0·Updated 7/17/2026·~16 min

What's changed: Initial version

5.4Layer 2 security

Key points

Covers port security that limits which MACs can connect to a switch port (violation modes protect/restrict/shutdown, sticky MAC), DHCP snooping that eliminates rogue DHCP servers (trusted/untrusted ports and the binding table), and Dynamic ARP Inspection (DAI) that uses those bindings to prevent ARP spoofing—so you can judge which L2 controls to combine from an attack scenario.

Even if you harden L3 and above with firewalls and ACLs, an attacker who plugs a device into an internal-LAN switch port can carry out Layer 2 attacks such as MAC flooding, a rogue DHCP server, and ARP spoofing. Because L2 attacks occur "within the same segment," L3 controls cannot stop them. This section covers the three representative L2 security features you should enable on access switches, focusing on "which attack each one stops and by what mechanism."

5.4.1Port security

  • Port security limits the number and identity of MAC addresses allowed on an access port. When the allowed count is exceeded or a disallowed MAC appears, it is handled as a "violation." The baseline config is switchport mode accessswitchport port-securityswitchport port-security maximum N (the maximum). The default maximum is 1.
  • Allowed MACs can be registered manually (switchport port-security mac-address ADDRESS) or via sticky MAC (switchport port-security mac-address sticky), which dynamically learns the first MAC into the allow list and saves it to the running-config. This pins "the legitimate device currently connected" without manual entry.
  • The violation action is chosen from three via switchport port-security violation. protect silently drops violating frames (no log or counter increment). restrict drops violating frames and sends an SNMP trap/Syslog and increments the counter. shutdown (the default) puts the port into an err-disabled state, shutting it down, and notifies; recovery requires shutdown then no shutdown, or errdisable recovery.

Continue reading — free sign-up

You're reading the free preview. Sign up free to read this section in full, plus every chapter (including 4+) and all questions.