DHCP
Overview
The Dynamic Host Configuration Protocol (DHCP) is a client/server protocol used to assign configuration information to hosts (and sometimes routers). At its most basic, it assigns clients an IP address and subnet mask, and provides the IP addresses of a DNS server and router.
DHCP is an extension of a now obsolete protocol called Internet Bootstrap Protocol (BOOTP). In particular, it extends the BOOTP model with the concept of leases which allow clients to use provided configuration information for an agreed-upon amount of time. BOOTP and DHCP employ UDP/IP for the exchanging of configuration data.
Address Allocation
A DHCP server can provide three levels of address allocation:
- Dynamic Allocation. A client is given a revocable IP address from a pool of addresses configured on the server.
- Automatic Allocation. A client is given an IP address from a pool of addresses configured on the server. It is never revoked.
- Manual Allocation. The DHCP protocol simply conveys an address already fixed for a requesting client.
Dynamic allocation is the most commonly used level. When a DHCP client requests an IP address, the server responds with an address selected from a (usual contiguous range of IP addresses) pool. The address is allocated to the client for a specific amount of time called the lease duration. The client may request a lease extension as needed, typically after half of the lease duration has passed.
Message Format
The following is a diagram of the DHCP message format.

- Op (Operation). Indicates the message is a request (
1) or reply (2). - HW Type (htype). Specifies the type of hardware address. Shares a numbering space with those used in ARP's hardware type field.
- Transaction ID (xid). A random number chosen by the client and copied into responses by the server. Used to match replies with requests.
- Broadcast Flag. May be set by clients to indicate they cannot process unicast IP datagrams but can process broadcast datagrams.
- Client IP Address (ciaddr). Includes the IP address of the requestor, if known, and
0otherwise. - "Your" IP Address (yiaddr). An IP address filled in by a server when providing an address to a requesting client.
- Client Hardware Address (chaddr). A unique identifier of the client used in any way determined by the server. Typically the client's MAC address.
Options
Any fields needed by DHCP that were not present when BOOTP was designed are carried as options.
Of particular note is the DHCP Message Type option (53). It is 1-byte long and always used with DHCP messages. It has the following possible values:
DHCPDISCOVER(1)DHCPOFFER(2)DHCPREQUEST(3)DHCPDECLINE(4)DHCPACK(5)DHCPNAK(6)DHCPRELEASE(7)DHCPINFORM(8)DHCPFORCERENEW(9)DHCPLEASEQUERY(10)DHCPLEASEUNASSIGNED(11)DHCPLEASEUNKNOWN(12)DHCPLEASEACTIVE(13)
Protocol Operation
In a typical exchange, a client first broadcasts a DHCPDISCOVER message. Each server receiving the request responds with a DHCPOFFER message that includes an IP address in the "Your" IP Address field. The client determines with offer it will accept and broadcasts a DHCPREQUEST message with the Server Identifier option set. The server matching the request will then accept the request with a DHCPACK or reject the request with a DHCPNAK.
If the client has an IP address but needs other configuration data, it will send a DHCPINFORM request. The server will respond with a message tagged with DHCPACK or DHCPNAK.

Lease Timers
Two timers are set once a client acquires a lease of duration
- Renewal timer. Default value of
. - When this timer passes, the client attempts to renew its address with the same DHCP server.
- Rebinding timer. Default value of
. - When this timer passes, the client attempts to renew its address with any DHCP server.