Home / Articles / Introduction to DHCP

Introduction to DHCP

Dynamic Host Configuration Protocol

DHCP (Dynamic Host Configuration Protocol) is a network management protocol used on Internet Protocol (IP) networks whereby a DHCP server dynamically assigns an IP address and other network configuration parameters to each device on a network so they can communicate with other IP networks.

DHCP automates and centrally manages these configurations rather than requiring network administrators to manually assign IP addresses to all network devices. DHCP can be implemented on networks ranging in size from home networks to large campus networks and regional Internet service provider networks.

IP Address Allocation

DHCP supports three mechanisms for IP address allocation:

  1. Dynamic allocation — A network administrator assigns a range of IP addresses to DHCP, and each DHCP client on a LAN is configured to request an IP address from the DHCP server during network initialization. The request-and-grant process uses a lease concept with a controllable time period.

  2. Automatic allocation — DHCP assigns a permanent IP address to a client (chosen from its pool of available addresses). This differs from dynamic allocation only in that the DHCP server tries to reassign the same address each time.

  3. Static allocation (manual) — The DHCP server allocates an IP address based on a table of MAC address/IP address mappings. Only clients with a recognized MAC address will receive an IP address.

DHCP Message Structure

A DHCP message consists of the following fields:

Field Size Description
op 1 byte Message op code: 1=BOOTREQUEST, 2=BOOTREPLY
htype 1 byte Hardware address type (1 = Ethernet)
hlen 1 byte Hardware address length (6 for Ethernet MAC)
hops 1 byte Client sets to 0; relay agents increment this
xid 4 bytes Transaction ID — random number chosen by client
secs 2 bytes Seconds elapsed since client started the process
flags 2 bytes Broadcast flag and reserved bits
ciaddr 4 bytes Client IP address (if already has one)
yiaddr 4 bytes "Your" IP address — the address being offered
siaddr 4 bytes Next server IP address
giaddr 4 bytes Relay agent IP address
chaddr 16 bytes Client hardware address (MAC address)
sname 64 bytes Optional server hostname
file 128 bytes Boot file name
options variable Optional parameters

DHCP Options

The options field allows DHCP to carry additional configuration information. Options are encoded as type-length-value (TLV) triples. Common options include:

DHCP Message Flow (DORA)

The standard DHCP exchange is known as DORA:

  1. DHCP Discover — The client broadcasts a DHCPDISCOVER message on the network subnet using the destination address 255.255.255.255 to locate available DHCP servers.

  2. DHCP Offer — Each available DHCP server responds with a DHCPOFFER message that includes an available network address and other configuration parameters.

  3. DHCP Request — The client broadcasts a DHCPREQUEST message, telling all servers which offer it has accepted. All other servers know their offer was declined and can return the address to their pool.

  4. DHCP Acknowledge — The selected DHCP server sends a DHCPACK to the client, including the lease duration and any other requested configuration. The client then performs final network configuration.

If the server cannot satisfy the request, it sends a DHCPNAK (negative acknowledgment) and the client must start over.

Leases and Bindings

A DHCP lease is the amount of time a DHCP server grants a client permission to use an IP address. When a lease expires, the client must renew it or stop using the address.

A DHCP binding is the association between an IP address and a MAC address that the server maintains in its database. For static allocation, bindings are created manually. For dynamic allocation, bindings are created and destroyed as leases are granted and expire.