What is DHCP?
Dynamic Host Configuration Protocol (DHCP) provides a mechanism called plug-and-play connection. This mechanism allows a computer to join a new network and obtain IP addresses without manual intervention. Of course, the DHCP service is not only reflected in the automatic IP Address Allocation Process for the DHCP client, but also in the IP address renewal and release process.
Working Principle
When DHCP provides services, the DHCP Client transmits data through UDP port 68, while the DHCP server transmits data through UDP port 67.
During the automatic allocation of IP addresses for the DHCP client for the first time, the DHCP server has gone through the following four phases: discovery, provision, selection, and validation. For example:
Next we will describe the entire process of DHCP protocol work in detail:
1. the DHCP server passively opens UDP port 67 and waits for messages sent from the client;
2. DHCP clients send DHCP discovery packets from UDP port 68;
3. Any DHCP server that receives the DHCP discovery packet sends a DHCP provision packet, so the DHCP Client may receive Multiple DHCP provision packets;
4. The DHCP Client selects one of several DHCP servers and sends a DHCP request packet to the server;
5. The selected DHCP server sends a confirmation packet DHCPACK. From then on, the DHCP client can use this IP address. DHCP clients set two counters T1 and T2 Based on the lease period T provided by the server. Their time-out periods are 0.875 T and T, respectively. Request to update the lease period when the timeout time is reached;
6. If the lease period is over half, DHCP sends the request message DHCPREQUEST to update the lease period;
7. If the DHCP server agrees, the confirmation message DHCPACK is sent back. The DHCP client receives a new lease period and resets the timer;
8. If the DHCP server does not agree, the denial packet DHCPNACK will be sent back. In this case, the client must immediately stop using the original IP address and apply for a new IP address (return to step 2). If DHCP does not respond, repeat the work after step 6 when the lease period is 0.875T;
9. DHCP can terminate the lease period provided by the server at any time. In this case, you only need to send the release packet DHCPRELEASE to the DHCP server.
The above is the entire process of DHCP protocol work. The lease period mentioned above is the temporary time for IP addresses provided by DHCP to the customer.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.