A real-life situation
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 make their own laptop the gateway, so all traffic flows through it.
- 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. The rogue answers first. The home router is close and not busy, so its Offer arrives before R1's.
- 3. R1's offer arrives too late. Most clients accept the first Offer they receive, so PC A takes the wrong settings.
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:
- Blocks rogue servers. Server messages are only accepted on trusted ports.
- 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.
- 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 it works that way
DHCP has no built-in way to prove a server is genuine. A client simply takes the first offer. The switch, however, knows something the client doesn't: which port each message came in on. Real servers sit behind the uplink, never behind a desk socket. So the switch can apply a simple rule based on direction:
| Message | Sent by | On an untrusted port |
|---|---|---|
| DISCOVER, REQUEST | Client | Allowed (and checked) |
| RELEASE, DECLINE | Client | Allowed only from the port in the binding for that address |
| OFFER, ACK, NAK | Server | Dropped |
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, which makes it harder to fake many clients.
Because the switch watches every successful exchange, it ends up with a reliable list of "this IP belongs to this MAC on this port". That list is the binding table, and other features trust it. ARP security explains how Dynamic ARP Inspection (DAI) checks every ARP message against it, and IP Source Guard uses it to filter spoofed source IPs.
How it works step by step
Here is a normal lease through SW1, with snooping on for VLAN 10. Tap a message to see what the switch checks.
- MAC:
- 0011.2233.4455
- IP:
- 192.168.10.20
- VLAN:
- 10
- Interface:
- Gi1/0/1
The binding is removed when the lease expires, when the client sends a valid RELEASE, or when the port goes down.
And here is what happens to the rogue server once snooping is on:
- 1. PC A asks again. Client messages are allowed on untrusted ports, so the request is forwarded as before.
- 2. The rogue's offer is dropped. A server message on untrusted Gi1/0/5 is discarded at SW1 and logged. PC A never sees it.
- 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.
How to configure it on Cisco IOS
⚠️ 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 10Both are needed: the first turns the feature on globally, the second picks the VLANs it works in. Neither alone does anything.
interface GigabitEthernet1/0/24
description Uplink to R1 Gi0/1
ip dhcp snooping trustThe port toward the real DHCP server. All other ports stay untrusted.
interface range GigabitEthernet1/0/1 - 23
ip dhcp snooping limit rate 15Optional but recommended: at most 15 DHCP packets per second per user port. A port that goes over is err-disabled. There is no limit by default.
no ip dhcp snooping information optionStop SW1 adding DHCP option 82. Needed here because R1 is a Cisco IOS DHCP server on the same subnet, which drops requests carrying option 82 from a non-relay.
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 rejects that combination, and clients get no address. 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: the DHCP server for VLAN 10
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
dns-server 192.168.20.53
lease 1R1 hands out 192.168.10.20 and up, with itself as gateway. lease 1 = one day (86400 seconds).
! SW1
ip dhcp snooping
ip dhcp snooping vlan 10
no ip dhcp snooping information option
ip dhcp snooping database flash:dhcp-snooping.db
!
interface GigabitEthernet1/0/24
description Uplink to R1 Gi0/1
ip dhcp snooping trust
!
interface range GigabitEthernet1/0/1 - 23
ip dhcp snooping limit rate 15
!
errdisable recovery cause dhcp-rate-limitThe database line saves the binding table to flash, so it survives a reload. Auto-recovery brings a rate-limited port back after the default 300 seconds.
How to verify it
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
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
When the rogue server tries again, SW1 logs the drop:
%DHCP_SNOOPING-5-DHCP_SNOOPING_UNTRUSTED_PORT: DHCP_SNOOPING drop message on untrusted port, message type: DHCPOFFER, MAC sa: 00aa.bbcc.0005
What goes wrong and how to troubleshoot it
| Symptom | Likely cause | Check / fix |
|---|---|---|
| No client gets an address | Uplink not trusted, so every Offer is dropped | show ip dhcp snooping; add ip dhcp snooping trust on the uplink |
| No client gets an address, uplink is trusted | Option 82 added and rejected by an IOS DHCP server | no ip dhcp snooping information option, or trust option 82 on the server |
| Snooping configured but does nothing | Global ip dhcp snooping missing, or the VLAN doesn't exist | Look for "operational on following VLANs" |
| A user port goes err-disabled | More DHCP packets per second than the rate limit | show interfaces status err-disabled shows dhcp-rate-limit; raise the limit if it's a legitimate device |
| DAI blocks hosts after a switch reload | Binding table was lost and clients haven't renewed yet | Save bindings with ip dhcp snooping database |
%PM-4-ERR_DISABLE: dhcp-rate-limit error detected on Gi1/0/5, putting Gi1/0/5 in err-disable state
Common mistakes
- Trusting user ports "to be safe". A trusted port can host a rogue server; trust only the path to the real one.
- Forgetting the uplink between two switches. If the DHCP server is behind another switch, the trunk toward it must be trusted on every switch on the way.
- 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.
Key takeaways
- 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 and IP Source Guard rely on that table.
- Rate limiting stops DHCP starvation by err-disabling a flooding port.
Check yourself
DHCP snooping is enabled for VLAN 10 on SW1. A DHCPOFFER arrives on Gi1/0/5, an untrusted user port. What does SW1 do?
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?
Which information does a DHCP snooping binding contain?
A tool on one PC sends thousands of DHCPDISCOVER messages with random MACs. Which DHCP snooping setting stops it?
SW1 inserts option 82 and R1 is a Cisco IOS DHCP server on the same subnet. Clients get no address. Why?