Dynamic Host Configuration Protocol, DHCP

DHCP is a network service used to provide computer systems using TCP/IP with an automatic allocation of IP address as well as other IP parameters. It is implemented as a client server architecture. This means that the software necessary to deliver the service is configured in two parts:

DHCP Servers

Many network operating systems such as Novell Netware, Windows and Linux include DHCP server capability as part of the distribution software. Once the DHCP server software is installed, it must be configured to specify list(s) of IP addresses that it will provide. The individual lists of IP addresses managed by DHCP servers are often referred to as a range or scope.

IP parameters

As well as allocating IP addresses to clients, DHCP servers may also be configured to provide important IP parameters essential to normal operation. These include:

DHCP clients

The configuration of DHCP clients is relatively simple: wherever IP address details are to be set, chose the automatic option. This setting initiates a DHCP request when the system is started.

Address allocation

In general, DHCP servers allocate addresses in two ways:

Reserved

A reserved address means that a particular IP address is reserved for a specific MAC address, i.e. a single machine. This guarantees that the device will always get the same IP address. IP address reservations are useful/important in situations such as:

Dynamic

Dynamic addresses are allocated every time a requesting machine boots. Dynamically allocated addresses are provided on the basis of a lease.

Lease

The lease specifies the length of time that the client can hold the IP address. When a machine that has been allocated a dynamic address is turned off, the address will eventually be retreived and can be made available for another computer. A short lease can be useful in situations where there are insufficient addresses for all the computers on a subnet.

The Protocol

Among the details that DHCP messages can include are:

DHCP option modes include:

DHCP RFC 2131

The DHCP Lease process

To ensure that the processes of aquisition, maintenance and release of IP address is efficient and accurate, a number of steps are undertaken:

Step 1: IP Discovery

The client initiates the first step to aquisition by sending a DHCPDiscover packet. This packet is sent as a broadcast at both the IP (255.255.255.255) and Ethernet levels (FF-FF-FF-FF-FF-FF). Teh source IP address is set as 0.0.0.0. At the transport layer, UDP is used, and the packet is addressed to port 67 with a source of port 68. The DHCPDiscover packet contains the MAC address of the client.

Step 2: IP Lease Offer

All DHCP servers will respond to a DHCPDiscover packet with a DHCPOffer packet. This packet contains an IP address mask, a subnet mask, lease period and the IP address of the server offering the address.. The IP addresss offered is temporarily reserved by the server so that it is not offered to other clients. Offers may be sent as a unicast to the client MAC address.The destination UDP port of 68 is used to identify the client process.

Step 3: IP Lease Selection

The client accepts the first DHCPOffer packet it receives and responds with a DHCPRequest packet to select the IP address it has been offered. The message is sent as a broadcast so that any other servers that have made an offer can unreserve the addresses that they have made.

Step 4: Lease Acknowledgement

Once the chosen server receives the acceptance message from the client, it marks the the selected IP address as leased, and then responds with an acknowledgment packet called a DHCPAck. Servers may also respond with a negative acknowledgment, DHCPNack. Servers may use DHCPNak packets to signal a client that a renewal request for an old IP address cannot be serviced because the address has been allocated to another client. Negative messages can also be used if the client has been moved to another subnet during the lease. If any client receives a DHCPNack, it must stop using the IP address and request a new lease.

The DHCPAck packet contains any options specified by the server as well as the IP address itself and the subnet mask. When the client receives this packet, the parameters are incrporated into the TCP/IP stack and used as if they were set manually.

Step 5: Lease Renewal

When the lease period reaches the half way point, the client will send a new lease request packet, DHCPRequest. If there is no reason to reject this request, the server will respond with a DHCPAck. This will reset the lease period.

When a client starts up the TCP/IP stack, it will always attempt to renew use of the old address. If the lease period has still time left, it will continue to use the lease until it expires

Step 6: Lease Release

The client or the server can cancel the lease before it expires. This process is important for reclaiming IP addresses of clients that have moved or reconfigured as static.

Routed Networks

Because DHCP traffic is broadcasted, it will not be forwarded by routers by default. Several strategies can be used used for the implementation of DHCP service in routed networks:

DHCP Relay

To forward DHCP requests to the DHCP server on another subnet, a router or computer must be set up to relay the requests. When a DHCP relay agent detects DHCP traffic such as a discovery or renewal packet, it will forward the request as a unicast to the DHCP server's address set in it's relay properties. DHCP responses are sent back to the relay agent, and the agent broadcasts the response on to the subnet.

Note: DHCP relay and DHCP service must not be set up on the same machine, since both services use the same UDP ports.