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. Show
Components of DHCPHere are the components of DHCP to explain how it works.
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.
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.
Why it is important to use DHCP servers
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 AgentFigure 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.
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 AgentThe 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:
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:
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.
|