DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to dynamically assign an Internet Protocol (IP) address to any device so that it can communicate using IP. Every computer or a host in a network has to have an IP address for communication purposes. An IP address is an identifier for any device or computer on a network. An IP address can be assigned to a computer in two ways, that is static IP and dynamic IP. In static IP the user assigns an IP address manually to the device whereas, in dynamic IP addressing the DHCP server assigns dynamically a random IP address from the poll of available IP address.
Now let’s see how DHCP works step by step. Step 1, when a client computer boots up it sends a broadcast message, DHCP discover. It doesn’t matter where the client computer is, it would send this packet looking for a DHCP server. The destination IP address of the broadcast message is 255.255.255.255 and the message simply means hello. Strp2, suppose there is a DHCP server reachable to client, and hear the DHCP discover message from the client it responds back with a DHCP offer message. It’s a broadcast UDP packet and contains an offer of IP address, subnet mask, default gateway, and the lease duration. In step 3, the DHCP client or the computer respond back to the DHCP server, with a DHCP request message, which basically requesting the things been offered in step 2. In the last step 4, the server replies with a DHCP pack which is an acknowledgement packet.
A DHCP server assigns IP address to its client computers on a network from its scope and scope is a range of IP address that a DHCP server can handout. When a computer receives an IP address from the server it’s not actually owns the IP address and it’s actually a lease. A lease is an amount of time the computer can keep the IP address for networking without renewing it. This is to keep the DHCP server with enough availability of IP address. If you wanted to have a specific IP address for a particular device all the time, you can create a reservation on DHCP server. A reservation will make sure that, a particular client, identified by its MAC address will always be given the same IP address when the machine request IP credentials from server. Finally, DHCP is a service that runs on servers such as Microsoft server or a Linux server. It also can run as a service on routers.