Dynamic Host Configuration Protocol (DHCP) is a protocol used to provide fast, automatic, and central management for the allotment of IP addresses within a network. The Dynamic Host Configuration Protocol (DHCP) automates the assigned IP addresses, subnet masks, gateways, and other networking parameters. This is called dynamic or automatic addressing. The alternative to dynamic addressing is static addressing. In the static addressing, the network administrator manually assigns and configures IP addresses on hosts.
When a client device is turned on and connects to the network; the device requests an IP address from a DHCP server; the DHCP server chooses an address from a configured range of addresses called a pool and assigns it to the client device on lease bases.
DHCP is an ideal and efficient system on a larger network to configure IP address settings where client’s changes occurred frequently. New User may arrive and want connection and someone want to leave the network. Static IP address configuration is too difficult in such a larger network.
DHCP addresses are issued to clients on leased bases. When the lease period is expired; the address must be renewed by DHCP if the client is connected to the network. If the client has been powered down or taken off the network; the address is returned to the pool for reuse.
A variety of devices can be as DHCP servers. The DHCP server in most of the networks is generally a local and dedicated PC-based server. The home users 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 static addressing is used for network devices and DHCP is used for general purpose. The figure below illustrates the types of DHCP servers that can be used.
There are two types of DHCP, DHCPv4 and DHCPv6 both provide similar services for there clients. The main difference between DHCPv4 and DHCPv6 is the gateway, DHCPv6 does not provide 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 device configured for DHCPv4 boots up or connects to the network; the DHCP client sends broadcasts a DHCP discover message to discover any available DHCP server. When DHCP server receive (DHCPDISCOVER) message, it replies with a DHCPOFFER message. The offer message contains the IPv4 address including 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.
Incas of multiple DHCP servers exist on the network, and then the client may receive multiple DHCPOFFER messages. So, the client should choose between them, and sends a DHCPREQUEST message. The DHCPREQUEST message identifies the exact server and leases offer that the client is accepting. A client can also request an address that it had previously been allocated by the server and the server should allow the previously used IP address.
Once the offer has been made for the chosen IP address; the device responds to the DHCP server with a DHCPREQUEST packet to accept it; after which the server sends an ACK that’s used to confirm that the device has that specific IP address and to define the amount of time that the device can use the address before getting a new one. If the server decides that the device cannot have the IP address, it will send a NACK.
For example, the client requested the IPv4 address, or offered by the server; is still available, the server returns a DHCPACK (DHCP Acknowledge) message that acknowledges to the client that the lease has been finalized. If the offer is no longer valid, then the server responds with a DHCP negative acknowledgment (DHCPNAK) message. If a DHCPNAK message is returned to the client; then the selection process should start again with a new DHCPDISCOVER message from the client. When a client gets a lease, it should be renewed previous to the lease expiration through another DHCPREQUEST message. The DHCP server is responsible to assign are unique IP addresses to the host.
DHCPv6 has the similar set of messages, the messages are SOLICIT, ADVERTISE, INFORMATION REQUEST, and REPLY