Routelearn.net
Course menu

Course 13: Security FundamentalsLesson 1.2 (2 of 8 in this course)80 of 91 in the CCNA series

DHCP snooping

Stopping rogue DHCP servers with trusted and untrusted ports, and the binding table DAI relies on.

Intermediate · 10 min read

DHCP snooping is a switch security feature that classifies ports as trusted or untrusted, drops DHCP server messages arriving on untrusted ports, and records each lease in a binding table of MAC address, IP address, VLAN and port. It blocks rogue DHCP servers, and the binding table is used by features such as Dynamic ARP Inspection.

In simple terms: The switch only accepts DHCP answers from the port that leads to the real DHCP server. A fake server plugged in at a desk is simply ignored.

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.

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
  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. 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:

  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 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:

MessageSent byOn an untrusted port
DISCOVER, REQUESTClientAllowed (and checked)
RELEASE, DECLINEClientAllowed only from the port in the binding for that address
OFFER, ACK, NAKServerDropped

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.

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

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:

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
  1. 1. PC A asks again. Client messages are allowed on untrusted ports, so the request is forwarded as before.
  2. 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. 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 10

Both 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 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 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 option

Stop 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 1

R1 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-limit

The 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

Example output · based on Cisco documentation; exact format varies by platform and software version
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.
Example output · based on Cisco documentation; exact format varies by platform and software version
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
This is the table that Dynamic ARP Inspection checks every ARP message against. If a client is missing here, DAI will block its ARP replies. An empty table on a busy VLAN usually means the uplink isn't trusted, so no ACK was ever accepted.

When the rogue server tries again, SW1 logs the drop:

Example output · based on Cisco documentation; exact format varies by platform and software version
%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

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-disabledMore DHCP packets per second than the rate limitshow interfaces status err-disabled shows dhcp-rate-limit; raise the limit if it's a legitimate device
DAI blocks hosts after a switch reloadBinding table was lost and clients haven't renewed yetSave bindings with ip dhcp snooping database
Example output · based on Cisco documentation; exact format varies by platform and software version
%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 what stops a DHCP starvation attack, where a tool sends thousands of requests with fake MACs to use up every address in the pool.

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

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 is a Cisco IOS DHCP server on the same subnet. Clients get no address. Why?

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?
Not directly. A host with a static address never sends DHCP messages, so it gets no binding. That is fine for DHCP snooping itself, but features that rely on the binding table, such as Dynamic ARP Inspection, need an ARP ACL or a static binding for those hosts.
Is the binding table kept after a reload?
Not by default. It is held in memory and rebuilt as clients renew their leases. You can make the switch save it to flash or a server with ip dhcp snooping database, so DAI keeps working for existing clients right after a reload.