Sub topic 13
Rogue servers, starvation and DHCP snooping
This chapter assumes you know the Discover, Offer, Request, Acknowledge (DORA) exchange and the common options (router, DNS server, lease time). It also assumes you know what a VLAN and a switch port are. Here you will see how DHCP's lack of authentication is abused and which switch features limit the damage.
Why DHCP is easy to attack
DHCP has no built-in authentication. A client broadcasts a Discover to 255.255.255.255 and accepts whichever Offer it likes. A server has no proof that the client is who it claims to be. Both facts follow from the design: a host with no address has no credentials and no one it already trusts.
This gives two attack families:
- Attacks on the client. A rogue server answers clients with bad configuration.
- Attacks on the server. A starvation attack uses up the address pool so that real clients get nothing.
Both need only a device on the same broadcast domain, such as a laptop plugged into a wall port.
Rogue DHCP servers
A rogue DHCP server is any device that answers DHCP requests without being authorized by the network's administrators. There are two kinds.
- Accidental. Someone connects a home router to a office wall socket through one of its LAN ports. The router's built-in DHCP server starts handing out
192.168.0.xaddresses. This is the most common cause in practice. - Malicious. An attacker runs a DHCP server to redirect traffic.
A client picks an Offer by simple rules. Many clients take the first Offer that arrives. A rogue server on the same switch can often answer faster than a distant legitimate server, so it wins often, though not always.
What a rogue server can do
| Option the rogue sets | Effect on the client |
|---|---|
| Option 3 (router) points to the attacker | Traffic to other networks passes through the attacker, which allows interception (man in the middle) |
| Option 6 (DNS server) points to the attacker | Name lookups return forged answers, which can send users to fake sites |
| Wrong address range or mask | The client cannot reach the real network, which causes an outage |
| Very long lease | The bad settings persist for days |
Option 6 is often the most dangerous. The attacker does not have to carry the traffic. Forging DNS answers is enough to redirect users.
Spotting a rogue server
Watch for Offers and Acknowledgements (server-to-client messages) from addresses you do not recognize. Messages from servers use source port 67 and destination port 68:
sudo tcpdump -n -e -i eth0 'udp src port 67 and udp dst port 68'The -e flag prints the source MAC address, which helps you find the physical device. You can also send a probe and list every server that replies. Run this only on a network you are authorized to test:
sudo nmap --script broadcast-dhcp-discover -e eth0If the script shows two different "Server Identifier" values, two servers are answering on that segment.
DHCP starvation
A starvation attack exhausts the server's address pool. The attacker sends many Discover or Request messages, each with a different forged client hardware address (the chaddr field in the DHCP message). The server sees many different clients and leases an address to each one.
Consider a pool of 100 addresses (192.168.1.100 to 192.168.1.199) with a 12-hour lease. An attacker needs only 100 distinct fake chaddr values to take every address. Tools can do this in a few seconds. After that:
- Real clients that send Discover get no Offer.
- The addresses stay taken until the leases expire, up to 12 hours later, unless the attacker keeps renewing them.
- Clients that fail fall back to a
169.254.x.xaddress and lose connectivity.
Why starvation is often a first step
Starvation on its own is a denial of service. It becomes worse when combined with a rogue server. The attacker drains the real server, then runs a rogue server so that new clients can get an address only from the attacker. The attacker does not need to win a race anymore.
Why shorter leases do not fix it
A shorter lease releases addresses sooner, but the attacker can simply request them again. Lease length changes how long recovery takes after the attack stops. It does not stop the attack.
Defense: DHCP snooping
DHCP snooping is a switch feature that inspects DHCP messages passing through the switch and drops those that should not be there. It works on three ideas.
- Trusted and untrusted ports. You mark ports that lead to legitimate DHCP servers (or toward them, such as uplinks) as trusted. All other ports, normally client ports, are untrusted.
- Message filtering. On an untrusted port the switch drops server messages: Offer, Acknowledge and NAK. A client port has no reason to send them. Client messages (Discover, Request) are allowed.
- A binding table. The switch records each successful lease it sees: client MAC address, IP address, VLAN, port and lease time.
The block above is replaced by the diagram below.
Defending against starvation
Snooping has two checks that matter here.
- MAC address verification. On an untrusted port, the switch compares the Ethernet source MAC address of the frame with the
chaddrinside the DHCP message. A starvation tool that forges onlychaddrproduces a mismatch, and the switch drops the packet. On Cisco IOS this check is enabled by default. - Rate limiting. You can set a maximum number of DHCP packets per second on an untrusted port. If a port exceeds it, the switch puts the port into an error-disabled state, which shuts it down until an administrator or a recovery timer re-enables it.
An attacker can still forge both the source MAC and chaddr. That is why snooping is usually paired with port security, which limits how many different source MAC addresses a port may use. Together they stop both forms of the attack.
Example configuration
This is Cisco IOS syntax. Other vendors use different commands for the same ideas.
! Enable snooping globally and on the VLANs that carry clients
ip dhcp snooping
ip dhcp snooping vlan 10,20
! Keep the binding table across reboots
ip dhcp snooping database flash:dhcp-snooping.db
! Port toward the legitimate DHCP server or relay: trusted
interface GigabitEthernet0/1
description Uplink toward DHCP server
ip dhcp snooping trust
! Client ports: untrusted (the default), limited to 15 DHCP packets per second
interface range GigabitEthernet0/2 - 24
ip dhcp snooping limit rate 15
switchport port-security
switchport port-security maximum 2Check the result with:
show ip dhcp snooping
show ip dhcp snooping bindingThe binding output lists one row per lease: MAC address, IP address, remaining lease seconds, type (dhcp-snooping), VLAN and interface.
What the binding table is also used for
The binding table is valuable beyond DHCP. Two related features read it:
- Dynamic ARP Inspection (DAI) checks ARP packets against the table. A host that claims an IP address it was never leased has its ARP messages dropped. This blocks ARP spoofing.
- IP Source Guard filters traffic on a port so that only packets from the IP address and MAC address recorded in the table are allowed. This blocks hosts that use a made-up source address.
Both depend on the table being correct. Hosts with static addresses do not appear in it, so you must add static bindings for them or those features will block them.
Gotchas and limits
- Trust the right ports. If you forget to trust the uplink toward the DHCP server, the switch drops legitimate Offers and no client gets an address. This is the most common mistake after enabling snooping.
- Relay agents and Option 82. By default, a switch with snooping may insert Option 82 (relay agent information) into client messages. If a downstream device is a relay that already inserted it, the switch may drop the packet on an untrusted port. Check your vendor's setting for allowing Option 82 on untrusted ports when you chain devices.
- The binding table is lost on reboot unless you store it in a database file. Without it, DAI and IP Source Guard may block clients until they renew.
- Snooping works per switch and per VLAN. An unmanaged switch behind a client port is not covered. A rogue server behind such a switch is on an untrusted port and gets dropped, but the unmanaged switch hides the individual devices from the port limits.
- Authorized servers are not authenticated. Snooping filters by port. It does not prove that the server on a trusted port is genuine. Protect those ports physically and administratively.
- Windows Active Directory can authorize DHCP servers in a domain. This stops domain-joined Windows DHCP servers from starting unauthorized, but it does nothing against a home router or Linux machine.
Summary of defenses
| Threat | Main defense | Supporting defense |
|---|---|---|
| Rogue DHCP server | Snooping trusted and untrusted ports | Monitoring for unknown servers, controls on who can plug in devices |
| Starvation with forged `chaddr` | Snooping MAC address verification | Rate limiting |
| Starvation with forged source MACs | Port security MAC limit | Rate limiting, err-disable recovery |
| ARP spoofing after a lease | Dynamic ARP Inspection | Binding table |
| Spoofed source IP | IP Source Guard | Binding table |
Exercise
A switch has DHCP snooping enabled on VLAN 10. After the change, no client on VLAN 10 can get an address, but the DHCP server is working and reachable. What is the most likely cause, and how do you fix it?
Show answer
The port that leads to the DHCP server (or its relay) is untrusted, so the switch drops the server's Offer and Acknowledge messages. Mark that port with ip dhcp snooping trust.
Exercise
A DHCP pool has 50 addresses and a 24-hour lease. An attacker sends Discover messages with forged chaddr values but the frames use the attacker's real source MAC. Which two switch checks stop this, and why does forging the source MAC as well defeat only one of them?
Show answer
Snooping MAC verification drops packets where the Ethernet source MAC differs from chaddr, and port security limits the number of source MACs on the port. If the attacker also forges the source MAC, the verification check passes because the two values match. Port security still stops it once the port sees more source MAC addresses than its maximum.
Exercise
Why does a shorter lease time not protect against a starvation attack?
Show answer
The attacker can request the addresses again as soon as they are released, so the pool stays empty. A shorter lease only shortens the recovery time after the attack ends.