Introduction to DHCPv4

Every device on the internet even each device on any network needs a unique IP address. The network administrators can statically IP addresses to routers, servers and printers whose locations are not likely to change and usually the IP addresses assigned to these devices not changed. The static addresses also enable administrators to manage these devices remotely because the network administrator can easily access a device when they determine its IP address.

The users in an organization and a network usually change locations, physically and logically. So, it is very difficult and time consuming for network administrators to assign new IP addresses every time an employee change their locations. As well as, for mobile employees who are working from remote locations manually assigning and setting the correct network parameters not easy.

For assigning IP addresses automatically the Dynamic Host Configuration Protocol (DHCP) server was introduced. Using a centralized DHCP server administers can assign IP address dynamically from a single server. The DHCP server makes IP address management effective and ensures consistency across the organization and its branch offices. The DHCP has two versions, DHCPv4 for IPv4 address and DHCPv6 for IPv6 addresses. Our focus will be on DHCPv4 in detail.

DHCPv4 can assign IPv4 addresses including other network parameters dynamically. A dedicated server for DHCPv4 is useful, timesaving and easy to manage tool for network administrators. Although, in a small office and organization, Cisco router can be configured to provides DHCPv4 services without a dedicated server. A Cisco IOS also provide “Easy IP” like full-featured DHCPv4 server. DHCPv4 has three different address allocation mechanisms:

  • Manual Allocation– The DHCPv4 communicate with a pre-allocated IPv4 address which is assigned manually to the network devices.
  • Automatic Allocation– DHCPv4 automatically assigns IPv4 address to a device permanently, from a pool of available addresses.
  • Dynamic Allocation– DHCPv4 dynamically assigns IPv4 address from a pool of addresses for a limited period. The server assigns an address to a device on lease bases for a specific period.

Using dynamic allocation, clients lease the IP addressing information from a DHCP server for a specific period. The administrator defines the lease time according to the network resources and requirement and set the leases to time out at different intervals. When the lease time expires, the client must ask for another address, although the client is typically reassigned the same address. The figure below illustrates the DHCP process.

DHCPv4 Operation

As the figure above illustrates when a client computer communicates with a DHCPv4 server, the server assigns or leases an IPv4 address to that client and the client connects to the network with that leased IP address until the lease expires. Usually, IP server assigned IP addresses on lease bases, therefore, the client must contact the DHCP server periodically to renew the lease. When a lease expires, the DHCP server adds the IP address to the pool where it can be reallocated as needed. When the client boots or wants to connect and join a network, it begins the process to obtain an IP address on lease bases.  The client starts the process with a broadcast DHCPDISCOVER message.

DHCP Discover (DHCPDISCOVER)

The client has no valid IPv4 address at bootup, therefore, it uses DHCPDISCOVER message for fined the DHCPv2 server for IP address information. It uses Layer 2 and Layer 3 broadcast address to communicate with the server. The figure below illustrates the DHCPDISCOVER message.

Introduction to DHCPv4 6

DHCP Offer (DHCPOFFER)

Once DHCPv4 server receives a DHCPDISCOVER message from the client, it reserves the available IPv4 address to that client and creates an ARP packet containing the MAC address of the requesting client and the leased IPv4 address for that client. The figure below illustrates the DHCPOFFER message to the requesting client. The DHCPOFFER message is sent as a unicast message, using the Layer 2 MAC address of the server as the source Layer 2 address and the Layer 2 MAC address of the client as the destination.

Introduction to DHCPv4 7

DHCP Request (DHCPREQUEST)

The client accepts the first received DHCPOFFER message and sends back a DHCPREQUEST message to the server. Many large networks use multiple DHCPv4 servers. So, the DHCPREQUEST serves as a binding receipt notice to the chosen server for the offered information. The message also contains an implicit decline to any other servers that may have provided the client with a binding offer. The message is also sent back in the form of the broadcast to inform all available servers in the network. The DHCPREQUEST is also used for lease renewal.

Introduction to DHCPv4 8

DHCP Acknowledgment (DHCPACK)

The server replies with a DHCPACK message to finish the DHCP session. DHCPACKt verifies the lease information with an ICMP ping to the leased address to check that it is not used anywhere else. If the address is not being used it creates a new ARP entry for the client lease and sends a unicast DHCPACK message. This message is the duplicate of the DHCPOFFER message, excluding for a change in the message type field.

After receiving the DHCPACK, it records the address configuration information and performs an ARP lookup for the assigned address. If there is no response to the ARP, the client knows that the IPv4 address is valid and starts using it as its own. The figure below illustrates the DHCPACK message.

Introduction to DHCPv4 9

Lease Renewal

When the lease period has expired, the client sends a DHCPREQUEST message as unicast directly to the DHCPv4 server that previously offered the IPv4 address. If a DHCPACK is not received within a particular time then the client sends DHCPREQUEST message as broadcasts to get and renew an IP address from some other DHCPv4 servers. When the server receives the DHCPREQUEST message from the client, the server verifies the lease information using a DHCPACK message. The figure below illustrates the DHCP renewal process of DHCPv4.

Introduction to DHCPv4 10