Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document.
Note: Even the most advanced machine translation cannot match the quality of professional translators.
Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).

DHCP Implementation

DHCP Implementation

Modes for Interaction Between a DHCP Client and Server

To obtain a valid dynamic IP address, a DHCP client exchanges different messages with a server at different stages. Generally, a DHCP client and server interact in the following modes.

The DHCP client dynamically obtains an IP address.

Figure 3-4 Procedure for a DHCP client to dynamically obtain an IP address

As shown in Figure 3-4, when a DHCP client accesses the network for the first time, the DHCP client sets up a connection with a DHCP server through the following four stages.

Discovery stage: The DHCP client searches for the DHCP server.

In this stage, the DHCP client sends a DHCP Discover message to search for the DHCP server. The DHCP server address is unknown to the client, so the DHCP client broadcasts the DHCP Discover message. All the DHCP servers send Reply messages after they receive the Discover message. In this way, the DHCP client knows locations of the DHCP servers on the network.

Offer stage: The DHCP server offers an IP address to the DHCP client.

The DHCP server receives the DHCP Discover message, selects an IP address from the address pool, and sends a DHCP Offer message to the DHCP client. The Offer message carries information such as the IP address, lease of the IP address, gateway address, and DNS server address.

Request stage: The DHCP client selects an IP address.

If multiple DHCP servers send DHCP Offer messages to the DHCP client, the client receives the first DHCP Offer message. Then the client broadcasts a DHCP Request message including the information about the DHCP server address (Option 54 field).

The client broadcasts a DHCP Request message to notify all the DHCP servers that the client uses the IP address provided by the DHCP server in the Option 54 field and that all the other servers can use the assigned IP addresses.

Acknowledgment stage: The DHCP server acknowledges the IP address that is offered.

When the DHCP server receives the DHCP Request message from the DHCP client, the server searches the lease record based on the MAC address in the Request message. If there is the IP address record, the server sends a DHCP ACK message to the client, carrying the IP address and other configurations. After receiving the DHCP ACK message, the DHCP client broadcasts gratuitous ARP packets to detect whether any host is using the IP address assigned by the DHCP server. If no response is received within the specified time, the DHCP client uses the IP address.

If there is no IP address record or the server cannot assign IP addresses, the server sends a DHCP NAK message to notify the DHCP client that the server cannot assign IP addresses. The DHCP client needs to send a new DHCP Discover message to request a new IP address.

After obtaining the IP address, the DHCP client checks the status of the gateway in use before the client goes online. If the gateway address is incorrect or the gateway device fails, the DHCP client requests a new IP address using the four modes for interaction.

The DHCP client reuses the assigned IP address.

Figure 3-5 Procedure for the DHCP client to reuse the assigned IP address

As shown in Figure 3-5, when the DHCP client accesses a network for the second time, it set ups a connection with the DHCP server in the following procedure.

The client accesses a network for the second time with the IP address that does not expire. The client does not need to send a DHCP Discover message again. It directly sends a DHCP Request message carrying the IP address assigned in the first time, namely, the Option 50 field in the message.

After receiving the DHCP Request message, if the requested IP address is not assigned to another DHCP client, the DHCP server sends a DHCP ACK message to instruct the DHCP client to use the IP address again.

If the IP address cannot be assigned to the DHCP client, for example, it has been assigned to another DHCP client, the DHCP server sends a DHCP NAK message to the DHCP client. After receiving the DHCP NAK message, the DHCP client sends a DHCP Discover message to request a new IP address.

The DHCP client renews the IP address lease.

An expected lease can be contained in the DHCP Request message sent to the server for an IP address. The server compares the expected lease with the lease in the address pool and assigns a shorter lease to the client.

The IP address dynamically assigned to the DHCP client usually has a validity period. The DHCP server withdraws the IP address after the validity period expires. To keep using the IP address, the DHCP client needs to renew the IP address lease.

When obtaining an IP address, the DHCP client enters the binding state. The client is configured with three timers to control lease renewal, rebinding, and lease expiration respectively. When assigning an IP address to the DHCP client, the DHCP server also specifies values for the timers. If the server does not specify values for the timers, the client uses the default values. Table 3-5 lists the default timer values.

Table 3-5 Default values of timers

Timer

Default Value

Lease renewal

50% of the lease

Rebinding

87.5% of the lease

Lease expiration

Overall lease

Figure 3-6 Procedure for a DHCP client to renew the IP address lease time

As shown in Figure 3-6, when the DHCP client renews the IP address lease time, it set ups a connection with the DHCP server in the following procedures:

When 50% of the IP address lease (T1) has passed, the DHCP client unicasts a DHCP Request message to the DHCP server to renew the lease time. If the client receives a DHCP ACK message, the address lease is successfully renewed. If the client receives a DHCP NAK message, it sends a request again.

When 87.5% of the IP address lease (T2) has passed and the client has not received the Reply message, the DHCP client automatically sends a broadcast message to the DHCP server to renew the IP address lease. If the client receives a DHCP ACK message, the address lease is successfully renewed. If the client receives a DHCP NAK message, it sends a request again.

If the client has not received a Reply message from the server when the IP address lease expires, the client must stop using the current IP address and send a DHCP Discover message to request a new IP address.

The DHCP client releases an IP address.

When the DHCP client does not use the assigned IP address, it sends a DHCP Release message to notify the DHCP server of releasing the IP address. The DHCP server retains the DHCP client configurations so that the configurations can be used when the client requests an address again.