Which DHCP message is used by a client to inform a DHCP server that it accepts the assigned IP address?

Dynamic Host Configuration Protocol (DHCP) is a network management protocol that helps the users of network services, such as DNS, NTP, and all networking protocols based on UDP or TCP, to simplify the process of configuring devices on IP network networks. A DHCP server assigns an IP address and other configuration network parameters for each network system to connect in a complicated way with other IP networks. The DHCP is an update to an earlier BOOTP protocol.

Components of DHCP

Here are the components of DHCP to explain how it works.

  • DHCP server: This is a computer that runs DHCP and includes IP addresses and similar settings. It's usually a server or router, but anything like an SD-WAN system can be used as a host.
  • DHCP client: This is the endpoint receiving DHCP server configuration information. This can be a monitor, handheld unit, IoT terminal, or something else that needs network access. Any of the DHCP information is optimized for default reception.
  • Subnet: It is possible to break IP networks into subnets segments. Networks help ensure manageability in networks.

DHCP relay: This is a router or host which listens to client messages on the network and then transmits them to a configured server. The server returns answers to the relay handler, who transmits them to the recipient. This is good for centralizing DHCP servers instead of providing a node on a single subnet.

  • Lease: This is the period during which a DHCP client keeps the IP address. The user must extend a contract if it expires.

How does DHCP work?

DHCP operates on the app layer to assign an IP address to the client dynamically, and this takes place through the sharing of the DHCP transactions or DHCP conversation string.

  • DHCP Discovery: The DHCP client transmits DHCP server messages. The client machine will send a package with 255.255.255.255 or, if configured, a particular subset of the broadcast address. 255.255.255.255 is a special address for broadcasting that indicates "the network" that helps you to transmit a broadcast packet to your related network.
  • DHCP Offer: The message of DHCP Discover is transmitted to the client by sending the DHCP message, and the DHCP server gives the client an IP address (form IP address pool). This message contains the proposed DHCP client IP address, default gateway, client MAC address, server IP address, subnet mask, and lease information.
  • DHCP Request: In most instances, the client may receive several DHCP services since many DHCP servers operate in the network. If one server's IP address fails, other servers may backup the IP address. However, only one DHCP bid is approved by the customer. The client will forward a DHCP request to the offered address on one of the DHCP servers in reaction to the offer. The remaining DHCP servers also deleted all other IP addresses provided and returned them to the pool of available IP addresses.
  • DHCP Acknowledgment: The server sends a confirmation to the client about the DHCP lease confirmation. Each other configuration requested by the client can be submitted by the server. The initialization of the Protocol is finished at this stage and the new Interface configurations are visible to the client.

Why it is important to use DHCP servers

  • Proper IP configuration: The setting of IP address parameters must be correct, and an error can be made when working with inputs like "192.168.159.3." Typological errors are usually incredibly difficult to fix with the risk reduced by the use of a DHCP server.
  • Mitigated IP address conflicts: An IP address is required for each connected computer. However, a repeat address may be used only once,, and there is a conflict where one or both computers are not related. This could be possible when manually allocated addresses are provided, especially when several endpoints, including mobile devices, are linked only periodically. By using DHCP, each address is used only once.
  • Automation of IP address administration: Without DHCP, network administrators will have to manually allocate and cancel emails. Keeping track of which system has what address can be a futile activity, when devices need network connectivity and when they leave is almost impossible to understand This can be streamlined and centralized by DHCP so that network professionals are able to handle all locations from one position.
  • Efficient change management: DHCP makes moving addresses, scopes, or endpoints very convenient. For example, a company may want the IP address scheme to be modified from range to range. This latest information is configured to the DHCP server, and the information is distributed to new endpoints. Similarly, no network setup is appropriate if a network system has been upgraded and replaced.

When a DHCP client broadcasts DHCP Discover messages, only a DHCP server on the same network segment as the DHCP client can receive the messages. If the DHCP client is on a different network segment from the DHCP server, a DHCP relay agent must be deployed to forward DHCP messages between the DHCP client and server.

Depending on whether a DHCP relay agent is used, the way in which network parameters are allocated to a new DHCP client differs.

Network Parameter Allocation Without a DHCP Relay Agent

Figure 3-5 shows the message exchange process between a DHCP server and a new DHCP client when no DHCP relay agent is deployed. This process is called four-message exchange.

Figure 3-5  Message exchange between a DHCP server and a new DHCP client when no DHCP relay agent is deployed

Stage 1: The Discovery Stage

When a DHCP client accesses a network for the first time, it does not know the IP address of the DHCP server. To learn this information, the client broadcasts a DHCP Discover message in which the destination IP address is 255.255.255.255 to all devices (including the DHCP server or relay agent) on the network segment. The DHCP Discover message includes the client's MAC address (chaddr field), parameter request list (Option 55), and broadcast flag (flags field).

Stage 2: The Offer Stage

The DHCP server on the same network segment as the DHCP client receives the DHCP Discover message, selects an available IP address from the address pool that is on the same network segment as the IP address of the interface that receives the DHCP Discover message, and then sends a DHCP Offer message carrying the selected IP address to the DHCP client.

In most cases, an address pool specifies the lease of the IP addresses it contains. If the DHCP Discover message contains an expected lease, the server compares the expected lease with the specified lease and allocates an IP address with the shorter of the two leases to the client.

The DHCP server selects an IP address for a client from the address pool in the following sequence:

The IP address allocation order cannot be modified.

  1. IP address statically bound to the MAC address of the client on the DHCP server
  2. IP address specified in the Option 50 (requested IP address) in the DHCP Discover message
  3. IP addresses in Expired status in the address pool, that is, the allocated IP addresses whose lease time expires
  4. IP address in idle status that is found when the DHCP server searches IP addresses in a random order in an address pool (In V200R009C00 and earlier versions, the DHCP server searches IP addresses in a descending order.)
  5. If no available IP address is found, the address pool automatically reclaims the IP addresses in Expired and Conflict status. If an IP address is available after the reclaim, the server allocates this IP address. Otherwise, the DHCP client sends a DHCP Discover message again to request an IP address after the timeout interval for the client to wait for a response from the server expires.

You can specify certain IP addresses to exclude on the DHCP server. For example, if you have statically allocated 192.168.1.100/24 to your DNS server, you can exclude this IP address from the address pool on network segment 192.168.1.0/24 so that it is not allocated through DHCP. This helps prevent IP address conflicts.

To prevent a newly allocated IP address conflicting with existing IP addresses, the DHCP server sends an ICMP Echo Request packet before sending a DHCP Offer message. This ICMP packet contains the IP address to be allocated in both the source and destination IP address fields. The server can allocate the IP address if it receives no ICMP Echo Reply packet within the detection period (no client is using this IP address). If the server receives an ICMP Echo Reply packet within the detection period, the DHCP server lists this IP address as a conflicting IP address (as it is in use by another client), and then waits for the next DHCP Discover message to start the IP address selection process again.

The IP address allocated during the offer stage may not be the final IP address used by the client. This is because the IP address may be allocated to another client if the DHCP server receives no response 16 seconds after the DHCP Offer message is sent. The IP address for the client can be determined only after the request and acknowledgment stages.

Stage 3: The Request Stage

If multiple DHCP servers reply with a DHCP Offer message to the client, the client accepts only the first DHCP Offer message it receives. The client then broadcasts a DHCP Request message carrying the selected DHCP server identifier (Option 54) and IP address (Option 50, with the IP address specified in the yiaddr field of the accepted DHCP Offer message).

The DHCP Request message notifies all the DHCP servers of the IP address that the DHCP client has selected. The unselected IP addresses offered by other DHCP servers are then free to be allocated to other clients.

When a switch functions as a DHCP client (including the cloud management scenario) and multiple DHCP servers exist on the network, the DHCP client polls DHCP servers according to the sequence of receiving DHCP Offer messages. If the previous DHCP server fails to allocate IP addresses, the DHCP client selects the next DHCP server.

Stage 4: The Acknowledgment Stage

After receiving a DHCP Request message, the DHCP server sends to the client a DHCP Ack message that contains the IP address specified in the Option 50 field of the DHCP Request message.

To determine whether any other device is using this IP address, the DHCP client broadcasts gratuitous ARP packets after receiving the DHCP Ack message. The client can use this IP address if no response is received within the specified time. However, if the DHCP client receives a response within the specified time, this IP address is already in use. The client then sends a DHCP Decline message to the DHCP server and applies for a new IP address. The server lists this IP address as a conflicting IP address.

Occasionally, the DHCP server may not allocate the IP address specified in the Option 50 field because, for example, an error occurs during negotiation or it does not receive the DHCP Request message quickly enough. In this case, the server replies with a DHCP Nak message to notify the client that the requested IP address cannot be allocated. The client then sends a DHCP Discover message to apply for a new IP address.

Network Parameter Allocation with a DHCP Relay Agent

The message exchange process between a DHCP server and a new DHCP client when a DHCP relay agent is deployed is similar to that described in Network Parameter Allocation without a DHCP Relay Agent. The main difference is that the DHCP relay agent acts as an intermediary to forward DHCP messages between a DHCP server and client that would otherwise be unable to communicate with each other. The following describes how the DHCP relay agent functions in the message exchange process.

Figure 3-6 shows the message exchange process between a DHCP server and a new DHCP client when a DHCP relay agent is deployed.

Figure 3-6  Message exchange between a DHCP server and a new DHCP client when a DHCP relay agent is deployed

Stage 1: The Discovery Stage

When a DHCP relay agent receives a DHCP Discover message, it performs the following steps:

  1. Check the value of the hops field. If this value exceeds 16, the relay agent discards the message. Otherwise, the relay agent increases this value by 1 and proceeds to the next step.
  2. Check the value of the giaddr field. If this value is 0, the relay agent sets the giaddr field to the IP address of the interface receiving the DHCP Discover message. Otherwise, the relay agent does not change the field and proceeds to the next step.
  3. Change the destination IP address of the DHCP Discover message to the IP address of the DHCP server or the next-hop DHCP relay agent, and change the source IP address to the IP address of the interface connecting the DHCP relay agent to the client. The relay agent then unicasts this message to the DHCP server or the next-hop DHCP relay agent.

If there are multiple DHCP relay agents between the DHCP client and server, each the DHCP relay agent processes the DHCP Discover message using the same method.

Stage 2: The Offer Stage

After receiving a DHCP Discover message, the DHCP server selects an address pool on the same network segment as that specified in the giaddr field and allocates an IP address and other network parameters from the address pool. The DHCP server then unicasts a DHCP Offer message to the DHCP relay agent specified in the giaddr field.

When the DHCP relay agent receives a DHCP Offer message, it performs the following steps:

  1. Check the value of the giaddr field. If this value is the IP address of the interface receiving the DHCP Offer message, the DHCP relay agent discards the message. Otherwise, the relay agent proceeds to the next step.
  2. Check the value of the flags field. If this value is 1, the DHCP relay agent broadcasts a DHCP Offer message to the DHCP client. Otherwise, the DHCP relay agent unicasts a DHCP Offer message.

Stage 3: The Request Stage

The DHCP relay agent processes the DHCP Request message from the client in the same manner as that described in Stage 3: The Request Stage.

Stage 4: The Acknowledgment Stage

The DHCP relay agent processes the DHCP Ack message from the server in the same manner as that described in Stage 4: The Acknowledgment Stage.

What is the DHCP message which informs the server the client will not be using the assigned IP address anymore?

DHCP Release If the client does not need its allocated IP address any longer, it unicasts a DHCP Release message (Destination MAC=DHCP Server MAC (m2), Destination IP=DHCP Server IP (1.1. 1.254)) to the DHCP server.

What kind of message does the DHCP server use to confirm that the host can use the IP address?

The DHCP client broadcasts a message called a DHCP discover message. The server will reply with a DHCP offer message that includes an offered IP address, subnet mask, and some other data.

Which DHCP messages do clients typically send?

The client sends a DHCPREQUEST message to all servers with the IP address of the chosen DHCP server.

What is type of message that the client sends the DHCP server if the client lease is about to expire?

When the IP address lease time of the DHCP client expires, it sends a DHCPREQUEST unicast message directly to the DHCPv4 server that originally offered the IPv4 address.