DHCP
The Dynamic Host Configuration Protocol hands out IP addresses, gateway, DNS servers and other settings to clients. Whoever answers first configures the client, which is why rogue DHCP servers are dangerous.
- OSI layer
- 7 Application
- Carried in
- UDP
- Ports
- 67/udp (server), 68/udp (client), 546/547 udp (DHCPv6)
- Wireshark filter
dhcp- Encrypted
- no
Packet structure
Select a field to see what it does.
Wireshark still calls the protocol bootp in older versions (filter bootp before 3.0).
How it works
The four-message exchange is called DORA:
sequenceDiagram
participant C as Client 0.0.0.0
participant S as DHCP server
C->>S: DISCOVER (broadcast to 255.255.255.255:67)
S-->>C: OFFER yiaddr=10.0.0.50, router, DNS, lease
C->>S: REQUEST (broadcast, names the chosen server, option 54)
S-->>C: ACK (lease confirmed)
Note over C: Renew at 50 % of the lease (unicast), rebind at 87.5 % (broadcast)
Before using the address, many clients send an ARP probe to check nobody else has it.
Relays: DHCP broadcasts do not cross routers. A relay agent (ip helper-address) forwards them as unicast to the central server and fills in giaddr and often option 82 (switch and port).
Other messages: RELEASE (client gives the address back), DECLINE (address already in use), NAK (server refuses, e.g. wrong subnet), INFORM (client has an address and only wants options).
In Wireshark
| Filter | Shows |
|---|---|
dhcp | All DHCP (bootp in Wireshark 2.x) |
dhcp.option.dhcp == 1 | Discovers (2 Offer, 3 Request, 5 ACK, 6 NAK) |
dhcp.option.dhcp == 2 | Offers: who answers as server? |
dhcp.hw.mac_addr == aa:bb:cc:dd:ee:ff | One client |
dhcp.option.hostname | Client host names |
dhcp.option.request_list_item | Parameter request list (OS fingerprint) |
dhcp.option.type == 252 | WPAD offers |
dhcp.option.type == 121 | Classless static routes |
dhcpv6 | DHCPv6 |
What normal looks like: Offers and ACKs only from your DHCP servers or relays, one DORA per client per boot, renewals at half the lease time. Offers from an unknown source are a rogue server, by accident (home router) or on purpose.
Security notes
- Rogue DHCP server: the first offer wins, so an attacker hands out themselves as gateway or DNS server and becomes man-in-the-middle. Fix: DHCP snooping on switches (only trusted ports may send offers).
- DHCP starvation: thousands of Discovers with fake MACs exhaust the pool (
yersinia,dhcpstarv), often followed by a rogue server. Fix: port security, snooping rate limits. - WPAD and proxy settings: option 252 can point clients to a malicious proxy configuration.
- TunnelVision (CVE-2024-3661): option 121 routes can steer traffic around a VPN on many clients.
- Reconnaissance: host names, vendor class (option 60) and the parameter request list reveal device types and OS versions passively.
- No authentication: DHCP has none in practice. Trust comes from the switch configuration (snooping, Dynamic ARP Inspection and IP Source Guard build on its binding table).
Versions and related
- BOOTP: the predecessor; DHCP keeps its message format.
- DHCPv6 (RFC 8415) and SLAAC configure IPv6 hosts; Router Advertisements decide which one is used.
- PXE network boot uses DHCP options 66/67 and TFTP.
- Runs over UDP broadcast and gives clients their DNS servers.
References
- RFC 2131: Dynamic Host Configuration Protocol
- RFC 2132: DHCP options
- RFC 3046: Relay agent information option (82)
- RFC 8415: DHCPv6
- IANA BOOTP/DHCP options