Course contents

Chapter 12: Security FundamentalsLesson 4 of 19

DHCP snooping

Your PC received an address, but it belongs to the wrong network. How can the switch stop a desk-side DHCP server from supplying the settings? Let's follow where the replies enter the switch.

Intermediate · 10 min read

A home router on a desk socket

On Monday morning half the users on VLAN 10 can't reach the internet. Their PCs have addresses, but from the wrong range: 192.168.0.x with a gateway of 192.168.0.1. Someone has plugged a home wireless router into a desk socket (Gi1/0/5). Its built-in DHCP server is answering requests faster than R1, and every PC that takes its offer now sends traffic to a box that goes nowhere. An attacker could do the same thing on purpose and advertise itself as the gateway. A client that accepts those settings may send its off-subnet traffic towards the wrong device. Client offer-selection behaviour varies; we should not rely on the legitimate server winning a race.

DHCP (Dynamic Host Configuration Protocol) supplies settings such as an IPv4 address, mask and default gateway. DHCP snooping inspects DHCP traffic on selected switch VLANs and rejects server messages entering untrusted ports. It also records observed client leases. This is a port-direction policy, not cryptographic server authentication.

Diagram
A home router on a desk socket
A home router on a desk socket
DeviceSwitch portRole and addressing
PC ASW1 Gi1/0/1, untrustedVLAN 10 DHCP client; MAC 0011.2233.4455; example lease 192.168.10.20/24
R1 Gi0/1SW1 Gi1/0/24, DHCP-snooping trusted192.168.10.1/24; legitimate DHCP server and default gateway
Unauthorised serverSW1 Gi1/0/5, untrustedDesk-side device offering the wrong 192.168.0.0/24 settings
Read each row across: the left box names the item, the others describe it.

All three ports are access ports in VLAN 10 in this small lab; no relay or trunk is required. The /24 mask is 255.255.255.0. Gi1/0/1 is a physical switch-interface name, while DHCP uses UDP transport ports 68 at the client and 67 at the server. The IP addresses are not website URLs.

Diagram
A rogue DHCP server racing the real one
A rogue DHCP server racing the real one
Gi1/0/1Gi1/0/5Gi1/0/24 trustedGi0/1R1 (DHCP server)Gi0/1 192.168.10.1SW1VLAN 10PC AGi1/0/1 · untrustedunauthorisedRogue DHCP serverGi1/0/5 · untrusted

Device key: R1 (DHCP server) (router) · SW1 (switch) · PC A (computer) · Rogue DHCP server (home router)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • R1 (DHCP server): Gi0/1 192.168.10.1
  • SW1: VLAN 10
  • PC A: Gi1/0/1 · untrusted
  • Rogue DHCP server: Gi1/0/5 · untrusted
  1. 1. PC A asks for an address. The Discover is a broadcast, so SW1 floods it out of every port in VLAN 10, including Gi1/0/5.
  2. 2. The rogue answers first. The home router is close and not busy, so its Offer arrives before R1's.
  3. 3. A legitimate offer also arrives. This client selects the rogue settings in our example. Offer selection varies, so arrival order is not a security boundary.
Before snooping, both servers can offer settings on VLAN 10. The arrows are DHCP messages, not a user's web connection.

What DHCP snooping is

DHCP snooping is a switch feature that inspects DHCP messages and decides which ports may act as DHCP servers. (For how DHCP itself works, see the DHCP lesson.) It does three jobs:

  1. Blocks rogue servers. Server messages are only accepted on trusted ports.
  2. Records who got which address. It builds the DHCP snooping binding table: one entry per lease, with the client's MAC address, IP address, VLAN, port and lease time.
  3. Limits DHCP floods. It can cap how many DHCP messages per second a port may send.

Every port is untrusted by default. You mark as trusted only the ports that lead to a legitimate DHCP server.

Why the switch trusts ports, not servers

Ordinary DHCP offer exchange in this lab does not authenticate the server. The switch knows something the client doesn't: which port each message came in on. Real servers normally sit behind the uplink, not behind a desk socket. So the switch can apply a simple rule based on direction:

Diagram
Why the switch trusts ports, not servers
Why the switch trusts ports, not servers
MessageSent byOn an untrusted port
DISCOVER, REQUESTClientAllowed (and checked)
RELEASE, DECLINEClientAllowed only from the port in the binding for that address
OFFER, ACK, NAKServerDropped
Read each row across: the left box names the item, the others describe it.

The RELEASE and DECLINE check stops a different trick: an attacker sending a fake RELEASE on behalf of a victim to cancel the victim's lease. The switch also checks by default that the frame's source MAC matches the client MAC inside the DHCP message. That catches a mismatch; a source capable of forging both consistently is not authenticated by this check.

Accepted lease exchanges for clients on untrusted interfaces let the switch learn an observed MAC/IP/VLAN/interface relationship. That binding table is useful evidence, not proof that the endpoint can be trusted for every purpose. Dynamic ARP Inspection (DAI) can validate ARP claims on its untrusted ports using bindings or ARP ACL policy. IP Source Guard is another separately configured consumer; snooping alone does not filter all user IP traffic.

A normal lease, seen by the switch

Here is a normal lease through SW1, with snooping on for VLAN 10. Tap a message to see what the switch checks.

Step 1 of 5 · DHCPDISCOVER
VLAN 10 · 192.168.10.0/24
PC A
Gi1/0/1 untrusted
SW1
snooping VLAN 10
R1
via Gi1/0/24 trusted
New entry in the binding table
MAC:
0011.2233.4455
IP:
192.168.10.20
VLAN:
10
Interface:
Gi1/0/1

Device key: PC A (computer) · SW1 (switch) · R1 (router)

Arrows run from each message's sender to its receiver. Rows show message order, not separate cables or elapsed time to scale. Port numbers identify services or conversations, not physical switch sockets.

This diagram follows a fresh dynamic lease. Lease expiry, valid release and platform-specific interface or database handling affect entry lifetime; verify the current table rather than assuming persistence.

The observed lease connects PC A's MAC, assigned IP, VLAN and local access interface. DHCP message direction and UDP ports are separate from physical switch-port names.

And here is what happens to the rogue server once snooping is on:

Diagram
DHCP snooping dropping the rogue server's offer
DHCP snooping dropping the rogue server's offer
Gi1/0/1Gi1/0/5Gi1/0/24 trustedGi0/1R1 (DHCP server)Gi0/1 192.168.10.1SW1VLAN 10PC AGi1/0/1 · untrustedunauthorisedRogue DHCP serverGi1/0/5 · untrusted

Device key: R1 (DHCP server) (router) · SW1 (switch) · PC A (computer) · Rogue DHCP server (home router)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • R1 (DHCP server): Gi0/1 192.168.10.1
  • SW1: VLAN 10
  • PC A: Gi1/0/1 · untrusted
  • Rogue DHCP server: Gi1/0/5 · untrusted
  1. 1. PC A asks again. The allowed client request is forwarded towards the trusted server-facing interface.
  2. 2. An unsolicited rogue offer is dropped. A server message entering untrusted Gi1/0/5 is discarded at SW1; inspect supported counters or logging for the drop.
  3. 3. Only R1 is heard. R1's messages arrive on the trusted port, so PC A gets the right address and gateway, and SW1 records the binding.
With snooping operational on VLAN 10, the trusted ingress path accepts R1's replies while a server message entering the desk port is rejected.

Turning on snooping for VLAN 10

Based on Cisco IOS / IOS XE documentation, not run on a lab device. Configure the trusted uplink before or together with enabling snooping, or clients lose their leases at renewal time.

ip dhcp snooping ip dhcp snooping vlan 10

Apply after preparing the intended trust policy below. Both scopes are needed: globally enable DHCP snooping and select VLAN 10. This does not create the VLAN or configure the client access ports.

interface GigabitEthernet1/0/24 description Uplink to R1 Gi0/1 ip dhcp snooping trust

The port toward the real DHCP server. All other ports stay untrusted.

interface range GigabitEthernet1/0/1 - 23 ip dhcp snooping limit rate 15

Optional lab rate limit of 15 DHCP packets per second on the stated user interfaces. Choose production limits from legitimate client behaviour; a burst above the configured threshold can err-disable a port. The reference platform has no snooping rate limit configured by default.

no ip dhcp snooping information option

For this direct-server lab, disable option 82 insertion to avoid the untrusted zero-relay-address compatibility case described below. This is a lab choice, not a recommendation to remove option 82 from every network.

Option 82 in one paragraph

Option 82 (the relay agent information option) is a field the switch can add to client requests, saying which switch and port the request came from. A server can use it to pick an address. Cisco switches add it by default when snooping is on. The catch: the switch is not a real relay, so the packet has option 82 but an empty relay address (giaddr 0.0.0.0). A Cisco IOS DHCP server can reject that combination when it is not configured to trust the inserted information, and clients then get no address. Check the server's actual policy and drop evidence. Either disable insertion on the switch (as above) or, on the router, accept it with ip dhcp relay information trusted on the LAN interface.

Full example for SW1 and R1

! R1: global configuration, isolated lab interface GigabitEthernet0/1 ip address 192.168.10.1 255.255.255.0 no shutdown exit ip dhcp excluded-address 192.168.10.1 192.168.10.19 ip dhcp pool VLAN10 network 192.168.10.0 255.255.255.0 default-router 192.168.10.1 lease 1

R1 supplies available leases in the VLAN 10 /24, with itself as gateway. The example binding uses .20, but allocation order is not a security guarantee. lease 1 is one day. DNS is omitted because this lab tests IP addressing and gateway reachability, not name resolution.

! SW1: global configuration, prepare ports before enabling vlan 10 interface range GigabitEthernet1/0/1 - 5 switchport mode access switchport access vlan 10 no shutdown interface GigabitEthernet1/0/24 switchport mode access switchport access vlan 10 no shutdown ip dhcp snooping trust exit no ip dhcp snooping information option interface range GigabitEthernet1/0/1 - 23 no ip dhcp snooping trust ip dhcp snooping limit rate 15 exit ip dhcp snooping ip dhcp snooping vlan 10 ip dhcp snooping database flash:dhcp-snooping.db

SW1 stages the known server-facing trust path, enables global and VLAN inspection, then configures the database destination. The filename requests supported local persistence; inspect show ip dhcp snooping database for successful writes and recovery. Other user ports remain untrusted. No automatic err-disable recovery is enabled by this example.

Configuration order reference: Catalyst 9200 IOS XE 17.14.x database command. Enable snooping before configuring the database agent. A configured destination alone does not prove that current bindings have been written.

These commands assume an isolated Catalyst IOS XE 17.x-style access-switch lab and an IOS/IOS XE DHCP-server router. Start in global configuration mode after configure terminal. Confirm the original VLAN and DHCP service work before adding inspection. The database URL and flash support vary by image; use only a supported writable lab location and verify the agent's status.

Reading the trust settings and binding table

Illustrative Cisco IOS XE output written for this lesson, not a switch capture
SW1#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
10
DHCP snooping is operational on following VLANs:
10
...
Insertion of option 82 is disabled
...
Verification of hwaddr field is enabled
...
Interface                  Trusted    Allow option    Rate limit (pps)
-----------------------    -------    ------------    ----------------
GigabitEthernet1/0/1       no         no              15
GigabitEthernet1/0/2       no         no              15
GigabitEthernet1/0/24      yes        yes             unlimited
Check three things: the VLAN is operational (the VLAN must exist), option 82 insertion is what you expect, and only the uplink is Trusted: yes.
Illustrative Cisco IOS XE output written for this lesson, not a switch capture
SW1#show ip dhcp snooping binding
MacAddress          IpAddress        Lease(sec)  Type           VLAN  Interface
------------------  ---------------  ----------  -------------  ----  --------------------
00:11:22:33:44:55   192.168.10.20    86012       dhcp-snooping   10    GigabitEthernet1/0/1
00:11:22:33:66:77   192.168.10.21    85377       dhcp-snooping   10    GigabitEthernet1/0/2
Total number of bindings: 2
The row records an observed client lease, not the server's address or a gateway setting. DAI can use it for ARP arriving on DAI-untrusted interfaces when an ARP ACL does not decide the packet. An empty table may mean no fresh lease exchange was observed, the VLAN is not operational, replies were dropped or entries were lost. Check the actual client transaction before changing trust.

A supported logging configuration may report an event like this; exact messages and default logging vary:

Illustrative Cisco IOS XE output written for this lesson, not a switch capture
%DHCP_SNOOPING-5-DHCP_SNOOPING_UNTRUSTED_PORT: DHCP_SNOOPING drop message on untrusted port, message type: DHCPOFFER, MAC sa: 00aa.bbcc.0005

When clients stop getting addresses

If clients lose their addresses right after snooping is switched on, the usual suspects are an uplink left untrusted and option 82 being rejected by an IOS DHCP server. Check those two before anything else.

Diagram
When clients stop getting addresses
When clients stop getting addresses
SymptomLikely causeCheck / fix
No client gets an addressUplink not trusted, so every Offer is droppedshow ip dhcp snooping; add ip dhcp snooping trust on the uplink
No client gets an address, uplink is trustedOption 82 added and rejected by an IOS DHCP serverno ip dhcp snooping information option, or trust option 82 on the server
Snooping configured but does nothingGlobal ip dhcp snooping missing, or the VLAN doesn't existLook for "operational on following VLANs"
A user port goes err-disabledPossible DHCP rate-limit eventCheck the err-disable reason and log; stop the cause or adjust a justified limit before recovery
DAI blocks hosts after a switch reloadPossible missing or stale binding databaseInspect bindings and database-agent status; renew the isolated test lease or restore valid records
Read each row across: the left box names the item, the others describe it.
Illustrative Cisco IOS XE output written for this lesson, not a switch capture
%PM-4-ERR_DISABLE: dhcp-rate-limit error detected on Gi1/0/5, putting Gi1/0/5 in err-disable state
A port that sends DHCP faster than its limit is shut down. This is one way to contain an excessive DHCP message rate. A DHCP starvation attempt may send many requests using forged client identities to consume available addresses in the pool. A fixed per-port rate limit is not a guarantee against slower or distributed misuse.

Trust and VLAN mistakes

  • Trusting user ports "to be safe". A trusted port can host a rogue server; trust only the path to the real one.
  • Ignoring direction across several switches. Each snooping switch must deliberately allow legitimate server messages on the interface where they enter; do not trust every inter-switch port just because it is a trunk.
  • Enabling snooping globally but not per VLAN (or the reverse).
  • Setting a rate limit on the trusted uplink as low as on user ports. The uplink carries replies for everyone.
  • Turning on Dynamic ARP Inspection before the binding table has filled up, which blocks legitimate hosts.

Exam tip: know that all ports are untrusted by default, that untrusted ports drop server messages (OFFER, ACK, NAK), and that you trust the port toward the real server. Expect a question linking DHCP snooping to DAI: DAI validates ARP against the DHCP snooping binding table. Also remember that ip dhcp snooping vlan is needed as well as the global command, and that exceeding ip dhcp snooping limit rate err-disables the port.

What to remember about DHCP snooping

  • DHCP snooping blocks DHCP server messages on untrusted ports, which is every port by default.
  • Trust only ports that lead to a legitimate DHCP server.
  • It builds a binding table (MAC, IP, VLAN, port, lease) from ACKs it sees.
  • Dynamic ARP Inspection can use that table or approved ARP ACL policy; IP Source Guard has its own supported binding policy.
  • Rate limiting can contain excessive traffic on a port, but it does not authenticate hosts or stop every starvation pattern.

Short lab: verify the lease, then a wrong trust policy

  1. With only R1's approved service active, request a fresh DHCP lease on PC A. Record its actual address, /24 mask and gateway. Check the matching SW1 binding, including Gi1/0/1 and VLAN 10, then ping 192.168.10.1.
  2. In a separate isolated fault snapshot, apply no ip dhcp snooping trust under SW1 Gi1/0/24. Request a new test lease after releasing the old one using the lab client's controls. An existing valid lease can keep working until renewal; it does not prove new server messages are accepted.
  3. Inspect the trust output and supported drop counters or logs. Restore ip dhcp snooping trust on Gi1/0/24, renew the client lease and recheck the binding and gateway ping. Leave user ports untrusted.

Technical reference: Cisco Catalyst DHCP snooping, binding database and option 82. All output is illustrative; no hardware validation or attack-blocking guarantee is claimed.

Test yourself on DHCP snooping

Predict · scenario 1

DHCP snooping is enabled for VLAN 10 on SW1. A DHCPOFFER arrives on Gi1/0/5, an untrusted user port. What does SW1 do?

Predict · scenario 2

After enabling DHCP snooping, no client gets an address. show ip dhcp snooping shows Gi1/0/24 (the uplink to the server) as Trusted: no. What fixes it?

Predict · scenario 3

Which information does a DHCP snooping binding contain?

Predict · scenario 4

A tool on one PC sends thousands of DHCPDISCOVER messages with random MACs. Which DHCP snooping setting stops it?

Predict · scenario 5

SW1 inserts option 82 and R1's DHCP-server logs confirm it rejects option 82 with giaddr 0.0.0.0 under its current trust policy. Why do clients get no lease?

FAQ

Which ports should be trusted for DHCP snooping?
Only ports that lead toward a real DHCP server: the uplink to the router or distribution switch, and the port of a DHCP server if it is attached locally. Every port facing end users stays untrusted, which is the default.
Why did all my clients stop getting addresses after I enabled DHCP snooping?
Usually one of two things. Either the uplink toward the DHCP server was not set as trusted, so the server's offers are dropped, or the switch is adding DHCP option 82 and a Cisco IOS DHCP server is rejecting those requests. Trust the uplink, and either disable option 82 insertion on the switch or tell the server to accept it.
Does DHCP snooping protect hosts with static IP addresses?
A manually addressed host does not acquire a DHCP lease, so that configuration alone creates no dynamic snooping binding. DHCP server-message filtering still operates on the port, but binding-dependent features need a separate policy. For DAI, use a correctly scoped ARP ACL for approved static hosts rather than assuming any static source-binding command is consumed by every feature.
Is the binding table kept after a reload?
Dynamic entries are normally held in memory. A configured database agent can save and restore them using supported local or remote storage. Verify successful writes, restoration and valid leases; simply entering a filename does not prove a current usable copy exists. Plan dependent features such as DAI for a missing or stale database after restart.