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 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.

dhcp-message-format.png

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:

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.

dhcp-protocol.png

Lease Timers

Two timers are set once a client acquires a lease of duration T:

  1. Renewal timer. Default value of T/2.
    1. When this timer passes, the client attempts to renew its address with the same DHCP server.
  2. Rebinding timer. Default value of 7T/8.
    1. When this timer passes, the client attempts to renew its address with any DHCP server.
Powered by Forestry.md