The Dynamic Host Configuration Protocol (DHCP) dynamically assigns IP addresses to hosts and centrally manages host configurations. DHCP uses the client/server model. A client applies to the server for configuration parameters, such as an IP address, subnet mask, and default gateway address; the server replies with the requested configuration parameters.
With the DHCP client function configured, a device uses DHCP to dynamically request an IP address from the DHCP server. This achieves appropriate assignment and centralized management of IP addresses.
To obtain a valid dynamic IP address, a DHCP client exchanges different information with the DHCP server at different stages. Generally, the DHCP client and server interact in the following modes:
A DHCP client dynamically obtains an IP address.
Discovery stage: The DHCP client searches for a DHCP server. The DHCP client broadcasts a DHCPDISCOVER message and only DHCP servers respond to the message.
Offer stage: Each DHCP server offers an IP address to the DHCP client. After receiving the DHCPDISCOVER message from the DHCP client, each DHCP server selects an unassigned IP address from the IP address pool, and sends a DHCPOFFER message with the leased IP address and other configurations to the DHCP client.
Request stage: The DHCP client selects an IP address. If multiple DHCP servers send DHCPOFFER messages to the DHCP client, the DHCP client accepts the first DHCPOFFER message it receives, and broadcasts to each DHCP server a DHCPREQUEST message carrying information about the selected IP address.
The DHCP client updates the lease period.
Some DHCP clients use a fixed IP address for a long time, and some DHCP clients use a temporary IP address. After a DHCP client's lease time is expired, the DHCP server reclaims the IP address of the DHCP client and allocates this IP address to another DHCP client. You can configure an expected lease time for a DHCP client as required. In this case, while assigning an address lease time, the DHCP server compares the expected lease time with the address lease time of the current address pool and provides the DHCP client an appropriate lease time based on address assignment rules.
After the lease time configured for a DHCP client to obtain a dynamic IP address from the DHCP server is expired, if the DHCP client wants to continue using this IP address, the IP address lease needs to be renewed.
The DHCP client proactively releases the IP address.
When the DHCP client no longer uses the assigned IP address, it proactively sends a DHCP Release message to the DHCP server to instruct the server to release the IP address lease. The DHCP server retains the DHCP client's configuration for reuse in case that the client re-applies for an IP address.