Watch on Instagram

Network Bytes · Episode 59 · CCNA 5.7

"DHCP snooping and rogue DHCP"

A rogue DHCP server that answers first can make itself every victim's default gateway and sit in the middle of their traffic. DHCP snooping stops it on the switch by trusting only the ports toward the real server and dropping server messages everywhere else.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

Why the first offer matters

When a device joins a network it broadcasts a DHCP Discover asking "is there a DHCP server out there?". Any server that hears it can reply with an offer: an IP address plus settings such as the subnet mask, the DNS server and the default gateway (the router option in RFC 2131). Clients generally accept the first offer that arrives. The default gateway is where the device sends everything that is not on its own subnet, which for most traffic means: everything.

The rogue DHCP attack

An attacker plugs a rogue DHCP server (a laptop or a small box) into any access port and replies to Discovers faster than the real server. Victims who take its offer get the attacker's machine as their default gateway, so every packet leaving the subnet passes through it before the attacker forwards it to the real router. That is a man-in-the-middle attack: the attacker can read, log or change the traffic. A rogue server can also hand out a fake DNS server to send victims to look-alike sites. Rogue servers are not always malicious: a home router plugged into an office network can cause the same outage by accident.

How DHCP snooping works

DHCP snooping is a switch feature that sorts ports into two kinds:

  • Untrusted (the default for every port): the switch drops DHCP server messages (Offer, Ack, Nak) that arrive here, and can rate-limit client messages.
  • Trusted: the port or uplink toward the legitimate DHCP server. Server messages are allowed in.

On a Cisco switch you turn it on globally and per VLAN, then trust the server-facing interface:

`` ip dhcp snooping ip dhcp snooping vlan 10 interface GigabitEthernet0/1 ip dhcp snooping trust ``

In a real network the trusted port is often an uplink to a distribution switch or to a router running DHCP relay, not the server itself.

The binding table

While it watches DHCP, the switch records each successful lease in a binding table: MAC address, IP address, lease time, VLAN and port. That table is the foundation for two more Layer 2 protections: Dynamic ARP Inspection (drops ARP replies that do not match a binding) and IP Source Guard (drops traffic from an IP that was not leased on that port).

Try it yourself

See which DHCP server and gateway your own computer got. On Windows, open a command prompt and run ipconfig /all, then look for "DHCP Server" and "Default Gateway". On macOS, run ipconfig getpacket en0 (or the name of your Wi-Fi interface) and look for server_identifier and router. On a home network both usually point at your home router. If the gateway were some other address you did not recognize, that would be worth a closer look.

Good to know

  • DHCP snooping is enabled globally and per VLAN (ip dhcp snooping, ip dhcp snooping vlan <n>).
  • All ports are untrusted by default; server-facing ports (or uplinks toward the server) are set with ip dhcp snooping trust.
  • On untrusted ports the switch drops DHCP server messages (Offer, Ack, Nak) and can rate-limit client messages.
  • The binding table holds MAC, IP, lease, VLAN and port, and is used by Dynamic ARP Inspection and IP Source Guard.
  • A rogue server can hand out a fake gateway or a fake DNS server; either way it is a man-in-the-middle attack.
  • Clients generally accept the first offer, which is why speed matters.

For CCNA learners

This lines up with CCNA 200-301 exam topic 5.7, configure and verify Layer 2 security features (DHCP snooping, dynamic ARP inspection, and port security): know that ports are untrusted by default, which port to trust, what gets dropped, and what the binding table is used for.

Answer to the comment question

1. Only the uplink toward the real DHCP server should be trusted. The 24 PC ports stay untrusted, because no legitimate DHCP server sits behind them; if someone plugs a rogue server into one of them, its offers are dropped.

Test your knowledge

Quick quiz: "DHCP snooping and rogue DHCP"

4 multiple-choice questions. Pick one answer for each, then check how you did.

1What does a rogue DHCP server usually hand out to get in the middle of your traffic?
2By default, how does DHCP snooping treat a switch port?
3An Offer arrives on an untrusted port. What does the switch do?
4Which of these is NOT stored in the DHCP snooping binding table?

Sources

Video transcript

How can a fake DHCP server steal your traffic?

When your laptop joins a network, it takes the first DHCP offer it hears. That offer sets your default gateway: where all your traffic goes.

An attacker plugs in a rogue DHCP server and answers faster. Now victims use the attacker's machine as their gateway, and every packet passes through it.

DHCP snooping stops this on the switch. Every port starts untrusted. You trust only the port facing the real server.

Server messages, like offers, arriving on an untrusted port get dropped. The switch also records who got which address, in a binding table.

A switch has 24 PC ports and 1 uplink to the real DHCP server. How many ports should be trusted? Comment your answer below!

That's your byte.

More from Network Bytes

All Network Bytes lessons