What is DHCP?
Dynamic Host Configuration Protocol (DHCP) is a client/server model that allows a server to dynamically distribute IP addressing and configuration information to clients. DHCP provides-
- IP address
- Subnet mask
- DNS server information
Any device based on the TCP/IP network must have a unique unicast IP address to communicate over an Internet/Intranet.
The DHCP protocol is widely used because it’s very hard to assign and configure static IP addresses on all TCP/IP network devices. With DHCP it’s very easy to allocate IP addresses to all hosts. We just need to install the DHCP server in every network segment. Any host who is running DHCP client, request for details during boot, when DHCP receives a request it will offer an IP address, subnet mask, and gateway. The IP allocation to a client is based on a lease, it means IP is allocated for a certain period. Once the lease will expire, the IP address will be renewed.
How DHCP Works?
There are eight types of DHCP protocol packet –
When a client boots up, it sends a DHCPDISCOVER message on its local network. The client broadcast the message with a destination IP address 2255.255.255.255. The client does not have a configured IP address, so the source address will be 0.0.0.0
When a DHCP server receives a DISCOVER message, it responds with an IP address and optional arguments like-
- Subnet mask
- Default gateway
- Domain name server details
- Lease time
- Renewal time
The DHCP server sends an OFFER message to the DHCP client mac address and the destination IP address is an offered IP address.
When the client receives a DHCPOFFER message, it sends a DHCPREQUEST message to the server if all parameters offered by the server is acceptable.
When the DHCP server receives and DHCPREQUEST message, it acknowledges the request with the DHCPACK message.