Loading content...
Every DHCP interaction—from initial address discovery to lease renewal to graceful shutdown—is conducted through a well-defined set of messages. These messages share a common structure inherited from BOOTP but extended with a flexible options mechanism that enables DHCP to deliver any configuration parameter imaginable.
Understanding DHCP messages at the packet level transforms debugging from guesswork to science. When a device fails to obtain an address, you can capture traffic and trace exactly where the process failed. When a server behaves unexpectedly, you can examine the options it's sending. When clients receive wrong configurations, you can identify the source.
This page dissects the DHCP message format, catalogs all message types and their specific purposes, and explores the options mechanism that makes DHCP extensible enough to serve modern enterprise networks.
By the end of this page, you will understand the complete DHCP packet structure, all eight message types and when each is used, and the options mechanism that enables DHCP to deliver configuration parameters beyond basic addressing. You'll be equipped to analyze DHCP packets with Wireshark or similar tools.
DHCP messages are encapsulated in UDP datagrams, which in turn are encapsulated in IP packets. The DHCP message itself follows the BOOTP format with extensions for the options field.
Transport Layer:
The DHCP Message Format:
| Field | Size | Description |
|---|---|---|
| op (opcode) | 1 byte | 1 = BOOTREQUEST (client to server), 2 = BOOTREPLY (server to client) |
| htype (hardware type) | 1 byte | Hardware address type (1 = Ethernet) |
| hlen (hardware length) | 1 byte | Length of hardware address (6 for Ethernet MAC) |
| hops | 1 byte | Relay agent hop count; set to 0 by client |
| xid (transaction ID) | 4 bytes | Random value correlating requests and responses |
| secs | 2 bytes | Seconds elapsed since client began acquisition |
| flags | 2 bytes | Broadcast flag (0x8000) if client requires broadcast response |
| ciaddr (client IP) | 4 bytes | Client's current IP (only if client already has one) |
| yiaddr (your IP) | 4 bytes | IP address assigned to client (server fills this) |
| siaddr (server IP) | 4 bytes | IP of next server (TFTP boot server) or responding server |
| giaddr (gateway IP) | 4 bytes | Relay agent IP (filled by relay, not client) |
| chaddr (client hardware) | 16 bytes | Client's MAC address (padded to 16 bytes) |
| sname (server name) | 64 bytes | Optional server hostname (or used for options overflow) |
| file (boot filename) | 128 bytes | Boot file path (or used for options overflow) |
| options | Variable | DHCP options (begins with magic cookie 0x63825363) |
Understanding Key Fields:
xid (Transaction ID): The xid is a random 32-bit value generated by the client for each new DORA transaction. All messages in the same exchange share this xid. Servers must copy the xid from the request into their response. This allows clients to:
ciaddr (Client IP Address): This field's meaning depends on context:
giaddr (Gateway IP Address): Filled by DHCP relay agents, not clients. When a relay forwards a broadcast to a remote server, it places its own IP in giaddr. The server uses this to:
1234567891011121314151617181920212223242526272829303132333435363738
DHCP Packet Memory Layout (RFC 2131)===================================== 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| op (1 byte) | htype (1) | hlen (1) | hops (1) | Bytes 0-3+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| xid (4 bytes) | Bytes 4-7+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| secs (2 bytes) | flags (2 bytes) | Bytes 8-11+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| ciaddr (4 bytes) | Bytes 12-15+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| yiaddr (4 bytes) | Bytes 16-19+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| siaddr (4 bytes) | Bytes 20-23+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| giaddr (4 bytes) | Bytes 24-27+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| chaddr (16 bytes) | Bytes 28-43| (client MAC padded with zeros) |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| sname (64 bytes) | Bytes 44-107| (optional server hostname) |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| file (128 bytes) | Bytes 108-235| (boot filename or options overflow) |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Magic Cookie (4 bytes): 0x63 0x82 0x53 0x63 (99.130.83.99) | Bytes 236-239+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| options (variable) | Bytes 240+| (TLV format, ends with option 255) |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Minimum DHCP message size: 300 bytes (per RFC 2131)Typical message size: 300-576 bytesMaximum message size: 576 bytes default, can negotiate higherDHCP defines eight message types, each serving a specific purpose in the protocol's operation. The message type is specified in Option 53 within the options field. Understanding when each message type is used is essential for troubleshooting.
The Eight DHCP Message Types:
| Type | Value | Direction | Purpose |
|---|---|---|---|
| DHCPDISCOVER | 1 | Client → Server | Client broadcasts to locate DHCP servers |
| DHCPOFFER | 2 | Server → Client | Server offers an IP address and configuration |
| DHCPREQUEST | 3 | Client → Server | Client requests offered address or renews lease |
| DHCPDECLINE | 4 | Client → Server | Client rejects address (detected conflict) |
| DHCPACK | 5 | Server → Client | Server confirms address assignment |
| DHCPNAK | 6 | Server → Client | Server denies request (invalid or changed) |
| DHCPRELEASE | 7 | Client → Server | Client voluntarily releases address |
| DHCPINFORM | 8 | Client → Server | Client requests configuration only (already has IP) |
DHCPDISCOVER (Type 1):
The first message in the DORA process, broadcast by a client seeking an IP address.
Client Behavior:
Timing:
DHCPOFFER (Type 2):
Server's response to DISCOVER, proposing an address.
Server Behavior:
Multiple Servers: If multiple servers are configured, each responds independently. Client collects offers and selects one.
DHCP's power comes from its extensible options mechanism. Options use a Type-Length-Value (TLV) format that allows the protocol to deliver virtually any configuration parameter while remaining backward compatible.
Options TLV Format:
+------+--------+----------------------+
| Type | Length | Value |
| 1 byte| 1 byte | Length bytes |
+------+--------+----------------------+
Special Options:
Magic Cookie:
The options field must begin with the magic cookie: 99.130.83.99 (0x63825363). This distinguishes DHCP packets from BOOTP packets and validates the options field.
Options Categories:
| Option | Name | Description |
|---|---|---|
| IP Layer | ||
| 1 | Subnet Mask | Network mask (e.g., 255.255.255.0) |
| 3 | Router | Default gateway list (one or more IPs) |
| 28 | Broadcast Address | Subnet broadcast address |
| 121 | Classless Static Routes | Static routes in CIDR format |
| DNS/Naming | ||
| 6 | Domain Name Servers | DNS server list |
| 15 | Domain Name | DNS domain suffix |
| 44 | NetBIOS Name Servers | WINS server list (legacy) |
| Time Services | ||
| 2 | Time Offset | Offset from UTC in seconds |
| 42 | NTP Servers | Network Time Protocol servers |
| DHCP Specific | ||
| 50 | Requested IP Address | Client's preferred address |
| 51 | IP Address Lease Time | Lease duration in seconds |
| 53 | DHCP Message Type | Message type (1-8) |
| 54 | Server Identifier | DHCP server IP address |
| 55 | Parameter Request List | Options client is requesting |
| 58 | Renewal (T1) Time | Seconds until renewal |
| 59 | Rebinding (T2) Time | Seconds until rebinding |
| 61 | Client Identifier | Alternative client ID (not MAC) |
Option 55 is crucial for efficient DHCP operation. The client sends a list of option codes it wants (e.g., 1, 3, 6, 15 for mask, gateway, DNS, domain). The server includes only requested options in its response, reducing message size. Well-configured clients request only what they need.
DHCP's options framework accommodates vendor-specific extensions and specialized use cases through dedicated option ranges and encapsulation mechanisms.
Vendor Class and Vendor-Specific Options:
PXE Boot Options:
Preboot Execution Environment (PXE) uses DHCP to provide boot information:
VoIP Phone Options:
IP phones often require specific configuration:
Modern Extensions:
| Option | Name | Use Case |
|---|---|---|
| 82 | Relay Agent Information | Switch port identification for location/policy |
| 119 | Domain Search List | DNS search path (replaces Option 15) |
| 121 | Classless Static Routes | CIDR routes (replaces Option 33) |
| 150 | TFTP Server Address (Cisco) | IP phones and network devices |
| 252 | WPAD (Web Proxy Auto-Discovery) | Proxy configuration URL |
Option 82 is inserted by switches/relay agents to identify the specific port and VLAN where the client is connected. This enables location-based addressing, security policies, and troubleshooting. Sub-options include Circuit ID (port) and Remote ID (switch identifier).
DHCP message size has implications for network compatibility and options capacity. Understanding size constraints is important for deploying complex configurations.
Historical Size Constraints:
Original BOOTP specified a minimum message size of 300 bytes. DHCP maintained this minimum for compatibility but also established limits:
Options Field Capacity:
With the fixed fields consuming 236 bytes (including magic cookie), the default options capacity is:
Options Overload (Option 52):
When options exceed the options field capacity, DHCP can overload the sname (64 bytes) and file (128 bytes) fields:
This provides up to 192 additional bytes for options without requiring large packets.
Maximum Message Size Option (Option 57):
Clients can advertise their capability to receive larger messages:
Option 57: Maximum DHCP Message Size
Length: 2 bytes
Value: Maximum bytes client can accept (e.g., 1500)
Servers should respect this option but cannot exceed the network's MTU. For reliability across diverse paths, staying at or below 1500 bytes is recommended.
DHCP messages exceeding 576 bytes risk IP fragmentation, which can cause delivery issues: fragments may be blocked by firewalls, arrive out of order, or be lost. For critical deployments, keep messages under 576 bytes or verify path MTU. Complex configurations with many options should be tested thoroughly.
DHCP uses a mix of broadcast and unicast communication depending on the message type and client state. Understanding this behavior is essential for network design and troubleshooting.
Why Broadcast?
DHCP must work before the client has any IP configuration. Broadcast (at Layer 2 and Layer 3) enables:
The BROADCAST Flag:
The flags field (offset 10-11) contains a BROADCAST flag (bit 15):
Why might a client need broadcast responses?
| Message | From | To | Transport |
|---|---|---|---|
| DISCOVER | Client (0.0.0.0) | Broadcast | Always broadcast |
| OFFER | Server | Client | Unicast to MAC, or broadcast if flag set |
| REQUEST (SELECTING) | Client | All servers | Always broadcast |
| REQUEST (RENEWING) | Client | Leasing server | Unicast |
| REQUEST (REBINDING) | Client | Any server | Broadcast |
| ACK/NAK | Server | Client | Unicast to MAC, or broadcast if flag set |
| RELEASE | Client | Server | Unicast |
| DECLINE | Client | Server | Unicast |
| INFORM | Client | Server | Unicast (client has IP) |
Layer 2 Unicast Before IP Configuration:
How can a server unicast to a client that doesn't have an IP address configured?
The answer lies in Layer 2: the server unicasts the Ethernet frame directly to the client's MAC address (from the chaddr field). The IP layer uses:
The client's network stack receives the frame because it matches the MAC address, even without IP configuration. This is why the BROADCAST flag exists—not all implementations handle this correctly.
Relay Agent Considerations:
When DHCP messages traverse relay agents:
When analyzing DHCP traffic, the giaddr field reveals the message's path. If giaddr is 0.0.0.0, the client and server are on the same subnet. If giaddr is non-zero, a relay agent forwarded the message, and giaddr identifies which subnet the client is on.
Practical DHCP troubleshooting requires the ability to capture and analyze DHCP traffic. Wireshark (and similar tools) decode DHCP packets completely, revealing all fields and options.
Capture Filter for DHCP:
port 67 or port 68
Display Filter for DHCP:
dhcp -- All DHCP packets
dhcp.type == 1 -- DISCOVER only
dhcp.type == 5 -- ACK only
dhcp.option.dhcp == 3 -- REQUEST messages
bootp.ip.your == 192.168.1.100 -- Specific yiaddr
Key Fields to Examine:
Common Troubleshooting Scenarios:
No OFFER received:
Wrong configuration received:
Lease renewal failures:
Slow DHCP performance:
1234567891011121314151617181920212223
Example DORA Exchange in Wireshark Summary View================================================ No. Time Source Dest Protocol Info1 0.000000 0.0.0.0 255.255.255.255 DHCP DISCOVER - Transaction ID 0xabcd12342 0.002341 192.168.1.1 192.168.1.100 DHCP OFFER - Transaction ID 0xabcd12343 0.003012 0.0.0.0 255.255.255.255 DHCP REQUEST - Transaction ID 0xabcd12344 0.004521 192.168.1.1 192.168.1.100 DHCP ACK - Transaction ID 0xabcd1234 Key Observations:- All messages share xid 0xabcd1234 (same transaction)- DISCOVER and REQUEST are broadcast (dst: 255.255.255.255)- OFFER and ACK are unicast to assigned IP (192.168.1.100)- Complete DORA in ~4.5ms (healthy network) Timing Issues Example:1 0.000000 0.0.0.0 255.255.255.255 DHCP DISCOVER2 4.002000 0.0.0.0 255.255.255.255 DHCP DISCOVER (retransmit)3 12.003000 0.0.0.0 255.255.255.255 DHCP DISCOVER (retransmit)4 12.015000 192.168.1.1 192.168.1.100 DHCP OFFER Problem: Server response delayed; client retransmitted twiceRoot cause: Check server load, network path, relay configurationWe've comprehensively examined DHCP message structure, types, and the options framework. Let's consolidate the key takeaways:
What's Next:
With DHCP message structure understood, the next page explores lease management—how leases are stored, renewed, expired, and reclaimed. Proper lease management is essential for maintaining healthy address pools and preventing exhaustion.
You now possess the knowledge to analyze DHCP traffic at the packet level, identify message types and their purposes, and understand the options framework that makes DHCP extensible. This enables effective troubleshooting and informed DHCP infrastructure design.