Dynamic Host Configuration Protocol (DHCP)
Dynamic Host Configuration Protocol (DHCP) is a protocol that provides fast, automatic, and central management for allotting IP addresses within a network. The Protocol automates the assigned IP addresses, subnet masks, gateways, and other networking parameters. This is dynamic or automatic IP addressing. The alternative to dynamic addressing is static addressing. In static addressing, the network administrator manually assigns and configures IP addresses on hosts.
When a client requests an IP address from a Dynamic Host Configuration Protocol server, the server chooses an address from a configured range of addresses called a pool and assigns it to the client device on a lease basis.
Dynamic Host Configuration Protocol is an ideal and efficient system on a more extensive network to configure IP address settings where the client’s changes occur frequently. A New User may arrive and want a connection, and someone may want to leave the network. Static IP address configuration is too complicated in such a more extensive network.
Clients get IP addresses automatically from the DHCP server on a leased basis. If the client is connected to the network and the lease period has expired, the dynamic host configuration protocol automatically renews the lease period. If the client powers down his device or unplugs the network cable, the address is free for the pool to reuse.
DHCP Servers
We can use a variety of devices as DHCP servers. The Dynamic Host Configuration Protocol server in most networks is generally a local and dedicated PC-based server. The home user’s DHCP server is usually a local router that connects the home network to the ISP. Several networks use both static and DHCP address settings.
The network administrator uses static addressing for network devices, and DHCP is for general purposes. The figure below illustrates the types of Dynamic Host Configuration Protocol servers that can be used.
Types of Dynamic Host Configuration Protocol
Two types of Dynamic Host Configuration Protocols, DHCPv4 and DHCPv6, give similar services to their clients. The main difference between DHCPv4 and DHCPv6 is the gateway. DHCPv6 does not give a default gateway address. The gateway can only be obtained automatically from the router’s Router Advertisement message.
Dynamic Host Configuration Protocol (DHCP) Operation
When a device configured for DHCPv4 boots up or connects to the network, the DHCP client sends a DHCP discover message to discover any available Dynamic Host Configuration Protocol server.
When the Dynamic Host Configuration Protocol server receives (DHCPDISCOVER) message, it replies with a DHCPOFFER message. The offer message has the IPv4 address, including a subnet mask, the IPv4 address of the DNS server, and the IPv4 address of the default gateway. The offer also includes the duration of the lease period.
Multiple DHCP servers
The client may receive various SCOFFERS messages if multiple DHCP servers exist on the network. So, the client should choose between them and send a DHCPREQUEST message. The DHCPREQUEST message identifies the exact server and lease offer the client accepts. A client can also request an address previously allocated to the client.
The server should allow the previously used IP address on a priority basis. Once the DHCP server has made an offer for the chosen IP address, the device responds to the DHCP server with a DHCPREQUEST packet to accept the offered IP address. Then, the server replies with an ack message to confirm the specific IP address for this device and define the lease time. If the server decides the device cannot have the IP address, it will send a NACK.
For example, if the client requests the IPv4 address or the server offers an address that is still available, the server returns a DHCPACK (DHCP Acknowledge) message. The message acknowledges to the client that the lease has been finalized. The server responds with a DHCP negative acknowledgement (DHCPNAK) message if the offer is no longer valid.
If the client received a DHCPNAK message, then the selection process should start again with a new DHCPDISCOVER message from the client. The client’s lease should be renewed before the lease expires through another DHCPREQUEST message. The DHCP server is responsible for assigning a unique IP address to the host. DHCPv6 has a similar set of messages: SOLICIT, ADVERTISE, INFORMATION REQUEST, and REPLY.