Skip to content

CCNA course / Keep the network secure · Step 3 of 13

Guide: Layer 2 securitySwitch

Guide

Layer 2 security: port security, DAI, storm control and RA Guard (CCNA and CCNP)

Layer 2 security features enforce trust at switch ports. This guide explains their purpose, common defaults and commands, and how to troubleshoot their effects on Cisco Catalyst IOS and IOS XE.

4 parts · 48 practice questions

Port security

Port security limits which source MAC addresses can use a switch port. It is commonly used on user-facing access ports, where a small maximum is reasonable. A trunk can also support port security on supported Catalyst platforms, but it may carry traffic for many devices, so a low limit can disrupt legitimate users. Configure a fixed access or trunk mode first; a dynamic access port is not compatible.

Default maximum
one secure MAC address per port
Default violation mode
shutdown
Default aging time
zero

Port security is disabled by default. After enabling it, the default maximum is one secure MAC address per port, the default violation mode is shutdown, and aging is disabled with a default time of zero. A new distinct source MAC beyond the maximum is a violation. A connected unmanaged switch does not hide the MAC addresses of devices behind it: each distinct source address counts toward the limit.

Sticky learning dynamically learns eligible source MAC addresses and adds them to the interface running configuration as sticky secure address commands, subject to the maximum. Save the running configuration to preserve those learned addresses across a reload. Sticky learning records observed addresses; it does not authenticate a person or device. Alternatively, configure a known static secure address directly under the interface with switchport port-security mac-address <mac-address>, then save the configuration to retain it across reloads.

Protect drops frames from unknown source MAC addresses without a violation counter increment or notification. Restrict also drops them, but increments the counter and sends a syslog message and SNMP trap. Shutdown is the default: it puts the interface into err-disabled state and increments the violation counter, but does not send a syslog message or SNMP trap. After fixing the cause, recover manually with shutdown followed by no shutdown, or configure errdisable recovery for psecure-violation. Recovery alone does not fix a continuing violation.

Aging can remove eligible secure addresses. Inactivity aging removes an address only after that address has been idle for the configured interval; absolute aging removes it after the interval regardless of traffic. A zero aging time disables aging. Whether static or sticky addresses can age is platform-dependent. For troubleshooting, show interfaces status can identify err-disabled state but does not prove its cause. Check logs and show port-security interface for the mode, maximum, learned count, and violation count; use show port-security address to list secure addresses and their type.

IOS XE
interface GigabitEthernet1/0/1
 switchport mode access
 switchport port-security
 switchport port-security maximum 1
 switchport port-security mac-address sticky
 switchport port-security violation restrict
 switchport port-security aging time 10
 switchport port-security aging type inactivity
show port-security interface GigabitEthernet1/0/1
show port-security address
show interfaces status
errdisable recovery cause psecure-violation
interface GigabitEthernet1/0/1
 shutdown
 no shutdown
Practice this part:CCNA: Port Security (15)
References (1)

Dynamic ARP Inspection (DAI)

ARP maps IPv4 addresses to link-layer MAC addresses on a local VLAN. Dynamic ARP Inspection intercepts ARP on enabled VLANs and checks packets arriving on untrusted interfaces. With DHCP Snooping bindings available, DAI compares the ARP sender IP and MAC with the client's trusted IP-to-MAC binding and drops a mismatch or an address with no matching binding. Enable DHCP Snooping and DAI for the relevant VLANs, and verify that the binding table is populated before expecting dynamically addressed clients to pass inspection.

DAI: check an ARP claim against a binding

SenderGi1/0/3DAI switchUntrusted portPeerARP cacheClaim MAC: 00:11:22:33:44:55Binding · VLAN 10 · Gi1/0/310.0.10.20 → 00:11:22:33:44:55AARP claim: I own 10.0.10.20

Start with the DHCP binding: this IP belongs to the MAC recorded in the table.

ARP sender: 10.0.10.20 / 00:11:22:33:44:55

Step 1 of 4

Begin with a known DHCP binding

DHCP snooping has learned that 10.0.10.20 belongs to MAC 00:11:22:33:44:55 on Gi1/0/3 in VLAN 10. DAI is enabled for the VLAN, and this host-facing port is untrusted.

More detail for this step
Start with the trusted record
  • ARP resolves an IPv4 address to a MAC address on the local network. A forged ARP claim can mislead a neighbour about that mapping.
  • DHCP snooping learns address allocations. Here its binding records the client IP, MAC, VLAN and switch port.
  • Untrusted means incoming ARP is inspected. It does not mean the port is disabled or that every connected host is malicious.

Read the caption, follow the highlighted action, then see its result. Pause or step through at your own pace.

Default DAI trust
All interfaces are untrusted
Default DAI VLAN state
disabled on VLANs
Default untrusted-interface rate
15 packets per second

All interfaces are untrusted by default for DAI. Host-facing ports are normally left untrusted. A router-facing port can be trusted when ARP arriving from that direction is authorized, but trust bypasses DAI checks, so do not treat every router link as automatically safe. DHCP Snooping trust and DAI trust are separate settings. A statically addressed host normally has no DHCP Snooping binding, so its ARP can be dropped on an untrusted port; configure an ARP ACL and apply it to the VLAN.

DAI is disabled by default on VLANs. The global command ip arp inspection vlan enables it for the specified VLAN or range. Optional validation adds checks to the binding lookup: src-mac checks the Ethernet source against the ARP sender MAC; dst-mac checks the Ethernet destination against the ARP target MAC for ARP replies; ip rejects invalid or unexpected IPs such as zero, broadcast, and multicast addresses. At least one validation keyword is required, and a later validate command replaces the earlier set, so combine the desired keywords in one command. Run ip arp inspection validate from global configuration mode, after exiting interface configuration mode.

The switch CPU performs DAI validation, so platforms rate-limit ARP arriving on untrusted interfaces. Catalyst documentation specifies a default of 15 packets per second on untrusted interfaces; check the target model and release rather than treating that number as universal. Exceeding the configured limit can put the port into err-disabled state. A legitimate busy port may need a higher limit. Diagnose DAI with show ip arp inspection statistics, which reports forwarded and dropped packets, MAC and IP validation failures, ACL permitted and denied packets, and DHCP permitted and denied packets by VLAN. DHCP denied counters identify packets rejected by the DHCP snooping binding check. Inspect bindings with show ip dhcp snooping binding and interface trust and rate with show ip arp inspection interfaces.

IOS XE
ip dhcp snooping
ip dhcp snooping vlan 10
ip arp inspection vlan 10
interface GigabitEthernet1/0/48
 ip arp inspection trust
interface GigabitEthernet1/0/1
 ip arp inspection limit rate 30
exit
ip arp inspection validate src-mac dst-mac ip
show ip dhcp snooping binding
show ip arp inspection interfaces
show ip arp inspection statistics vlan 10
References (1)

Storm control and IPv6 RA Guard

Storm control measures selected broadcast, multicast, or unicast traffic on an interface over a one-second interval. A rising threshold expressed with level is a percentage of interface bandwidth; for example, storm-control broadcast level 20 sets a 20 percent broadcast threshold. Catalyst platforms also support bits-per-second and packets-per-second thresholds. Once the threshold is reached, the switch filters traffic of that selected type until the rate falls below the configured falling threshold; if no falling threshold is set, filtering continues until the rate falls below the rising threshold. On Catalyst 9300, multicast control traffic such as BPDUs and CDP is exempt from multicast storm filtering. Percent thresholds are hardware approximations, so observed enforcement can differ by several percentage points depending on packet sizes. Storm control limits impact; it does not remove a Layer 2 loop, which Spanning Tree Protocol is designed to prevent.

Storm control measurement interval
one-second interval
Example broadcast threshold
20 percent
RA message type
type 134

Storm control is disabled by default. The default action when traffic crosses a configured threshold is filtering without an SNMP trap. storm-control action trap adds a notification while filtering continues. storm-control action shutdown instead error-disables the port; it does not resume forwarding when the rate falls below a threshold. Restore it with shutdown then no shutdown, or configured errdisable recovery. Use show storm-control to inspect the filter state, configured upper and lower thresholds, and current traffic level.

IPv6 hosts learn prefixes and default-router information from ICMPv6 Router Advertisement messages, type 134. A rogue host sending RAs can misdirect traffic or disrupt host configuration. RA Guard filters unauthorized RAs at Layer 2. Apply a policy with the host role to end-device ports so RAs received there are blocked, and configure the router-facing port with the router role so legitimate advertisements can pass. RA Guard is the IPv6 first-hop defense analogous in purpose to DHCP Snooping's filtering of rogue DHCPv4 server replies.

On IOS XE Catalyst releases that support this policy syntax, create an RA Guard policy, set its device role, and attach it on the interface. The router-facing interface also needs an appropriate router-role policy when the switch uses host-role policy on client-facing ports. Verify exact support and policy behavior for the switch and release in use.

IOS XE
interface GigabitEthernet1/0/1
 storm-control broadcast level 20
 storm-control action shutdown
show storm-control
ipv6 nd raguard policy HOSTS
 device-role host
interface GigabitEthernet1/0/1
 ipv6 nd raguard attach-policy HOSTS
ipv6 nd raguard policy ROUTER
 device-role router
interface GigabitEthernet1/0/48
 ipv6 nd raguard attach-policy ROUTER
References (3)

CCNP depth: ENCOR Layer 2 security

DHCP Snooping treats client-facing interfaces as untrusted by default and trusted interfaces as authorized paths for DHCP server messages. On an untrusted interface, inbound server-originated messages such as DHCPOFFER, DHCPACK, and DHCPNAK are dropped, preventing a rogue server from assigning clients a false gateway or other settings. Client requests such as DHCPDISCOVER are expected on untrusted ports. DHCP Snooping can learn client IP-to-MAC, VLAN, and interface bindings for use by DAI and IP Source Guard.

IP Source Guard (IPSG) prevents source IP spoofing on supported Layer 2 access interfaces. It uses a hardware source IP lookup table populated from DHCP Snooping or configured static IP source bindings; supported modes can filter on source IP alone or source IP and MAC. A legitimate static host needs an appropriate static binding. Do not assume IPSG should be placed on an uplink or trunk.

Unicast Reverse Path Forwarding (uRPF) checks an incoming packet's source IP against a reverse route lookup in the Cisco Express Forwarding FIB. In strict mode, the best return path must use the receiving interface; loose mode checks for a route without requiring that interface. This helps reject spoofed sources, but asymmetric routing can make strict checks drop legitimate packets. uRPF is an input-interface feature and requires CEF/FIB support; it is not an access-port DHCP Snooping binding check.

Control Plane Policing (CoPP) uses Modular QoS CLI policy classes and policers to limit traffic destined for the switch CPU, helping protect control-plane processing from floods and denial-of-service traffic. It is configured with a service policy under control-plane configuration mode. Exit policy-map submodes before entering control-plane. On Catalyst 9300 IOS XE 17.8, configured packet rates are rounded to the nearest multiple of 200, so 100 pps is applied as 200 pps. CoPP protects the CPU path; it does not replace per-port controls such as DAI rate limits or storm control. Catalyst implementations often use a system-defined control-plane policy, so do not replace or alter it without understanding platform guidance.

IOS XE
ip dhcp snooping
ip dhcp snooping vlan 10
interface GigabitEthernet1/0/48
 ip dhcp snooping trust
interface GigabitEthernet1/0/1
 ip verify source
ip source binding aaaa.bbbb.cccc vlan 10 192.0.2.20 interface GigabitEthernet1/0/1
interface GigabitEthernet1/0/1
 ip verify unicast source reachable-via rx
policy-map system-cpp-policy
 class system-cpp-police-protocol-snooping
  police rate 100 pps
exit
exit
control-plane
 service-policy input system-cpp-policy
References (4)

Check your understanding

Layer 2 security: port security, DAI, storm control and RA Guard (CCNA and CCNP)

All 4 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.