DHCP Protocol Overview and benefits

This post gives a high level overview of the Dynamic Host Configuration Protocol (DHCP), including its history, benefits and basic theory of operation.

This post gives a high level overview of the Dynamic Host Configuration Protocol (DHCP)  and its benefits.

DHCP is the most widely used auto-configuration protocol for assigning IP addresses and lot of other network related parameters  to end devices like computers, different types of workstations and to almost any type of IP-enabled end nodes. It is a plug-n-play protocol, for enabling end devices to auto-configure themselves on boot up. It is used on almost all types of networks, including home, office, corporate and campus networks.

Prior Protocols and their drawbacks

Before DHCP, two protocols, namely RARP and BOOTP were used for assigning IP addresses to end nodes. Both were client server protocols primarily used by end clients to get an IP address.

RARP is a layer 2 broadcast protocol and since routers do not forward broadcast packets, the RARP server is required to be present  in the same network as the clients.  This necessitated every network to have a dedicated RARP server.

To overcome this problem with RARP, BOOTP was developed, using UDP as the transport layer protocol. BOOTP packets where sent as Layer3 broadcasts. In cases where a BOOTP server was not present on the local network, a router acted as a relay, to forward BOOTP request messages onto a remote BOOTP server present in another network. Using BOOTP, it was possible to assign additional parameters like boot image location, boot image file name etc., apart from the client’s IP address. However, BOOTP required manual administration at the server end for entering the IP address and other information pertaining to each client. Hence, BOOTP does not scale well for large networks with more number of clients.

To overcome the problem of BOOTP, DHCP was developed as an enhancement of BOOTP. DHCP was devised in a way such that both client and server administration could be done automatically, with minimal manual intervention.

Basic Theory of Operation of DHCP

DHCP is a simple application layer, client-server based protocol, running on top of UDP.  DHCP protocol  can logically be split into three different pieces of software, namely DHCP client, DHCP server and DHCP Relay implementations. While DHCP client software runs on IP-enabled end nodes, DHCP server software is typically run on server machines. DHCP Relay software is implemented in routers, that act as intermediate relay agents of DHCP messages, for networks that do not have a dedicated DHCP server.
DHCP server runs on UDP port number 67, waiting for handing DHCP client requests. IP enabled end nodes run the DHCP client software in order to communicate with DHCP servers.
End nodes, on bootup, initiate a 4-way handshake message with a nearby DHCP server (as shown in the diagram below), in order to automatically get their IP address and other network related parameters.
DHCP protocol message exchanges for IP address assignment, renewal and release
DHCP protocol message exchanges for IP address assignment, renewal and release
The above diagram gives the typical message exchanges between clients and servers for IP address assignment, renewal and release. All the DHCP messages are sent as Layer2 and Layer3 broadcasts (with a destination MAC address of 0XFFFFFF and a  destination IP address of 255.255.255.255), so that all the DHCP servers in the network are aware of the DHCP transactions.
Advantages of DHCP
  • Simplifies the IP address assignment process of network administrators, as the whole process of IP address assignment can be automated. Using DHCP, devices can get their IP addresses and network related parameters automatically on boot up, without manual intervention, thereby facilitating a plug-n-play approach.
  • DHCP optimally uses IP address space, as DHCP mandates periodic renewal of assigned IP addresses. Those assigned IP addresses that are not renewed can be used for new end nodes.
  • DHCP supports both  static and dynamic modes of IP addresses assignment and both these modes can coexist together.  On a need basis, some nodes could always be assigned the same static IP addresses, based on their device identity like MAC addresses, while rest of the nodes could be assigned dynamic addresses from a pool of IP addresses configured on the DHCP server.
  •  DHCP can be used to assign not only IP addresses, but also a wide range of additional network parameters like default gateway, DNS server address etc.
  • DHCP framework permits vendor specific options to be included inside DHCP messages, so that end nodes can be assigned even vendor specific parameters.
  • With routers acting as DHCP relay agents, even end nodes that do not have a DHCP server in their network, can communicate with remote DHCP servers, to get their IP address and other network related parameters.
  • DHCP supports both IPV4 and IPV6 address assignments.