DHCP Server

A DHCP server assigns IP addresses to clients. A DHCP client sends a message to a DHCP server to request configuration parameters, such as the IP address, subnet mask, and default gateway address. The DHCP server responds with a message carrying the requested configuration parameters. Both the request and reply messages are encapsulated in UDP packets.

Modes for Interaction Between the DHCP Client and Server

To obtain a valid dynamic IP address, a DHCP client exchanges different information with a server at different stages. Generally, the DHCP client and server interact in the following modes (defined in standard protocols):
  • A DHCP client accesses a network for the first time.

    When a DHCP client accesses a network for the first time, the DHCP client goes through the following stages to set up a connection with a DHCP server:
    • 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.

    • Acknowledgment stage: The DHCP server acknowledges the IP address that is offered. After receiving the DHCPREQUEST message, the DHCP server sends a DHCPACK message to the client. The DHCPACK message contains the offered IP address and other settings. The DHCP client then binds its TCP/IP protocol suite to the network interface card.

    Except the IP address offered by the DHCP server selected by the DHCP client, the unassigned IP addresses offered by other DHCP servers are available for other clients.

  • A DHCP client accesses a network for the second time.

    When a DHCP client accesses a network for the second time, the DHCP client goes through the following procedures to set up a connection with the DHCP server:

    • If the client has previously accessed the network correctly, it does not broadcast a DHCPDISCOVER message. Instead, it broadcasts a DHCPREQUEST message that carries the previously assigned IP address.

    • After receiving the DHCPREQUEST message, the DHCP server responds with a DHCPACK message if the requested IP address is not assigned, notifying the client that it can continue to use the original IP address.

    • If the IP address cannot be assigned to the DHCP client (for example, it has been assigned to another client), the DHCP server responds with a DHCPNAK message to the client. After receiving the DHCPNAK message, the client sends a DHCPDISCOVER message to apply for a new IP address.

  • A DHCP client extends the IP address lease.

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

    In actual application, a DHCP client automatically sends a DHCPREQUEST message to the DHCP server to renew the IP address lease when the DHCP client is started or half the duration of the lease is remaining. If the IP address is valid, the DHCP server replies with a DHCPACK message to inform the DHCP client of the new lease.

  • A DHCP server forces a client to renew the IP address.

    To force a DHCP client to enter the RENEW state, configure a DHCP server to send a unicast FORCERENEW message to the client.

    • When the DHCP client attempts to renew its lease by unicasting a DHCPREQUEST message to the DHCP server according to the DHCP lease renewal process: If the DHCP server replies with a DHCPACK message, the lease is successfully renewed. If the DHCP server replies with a DHCPNAK message, the DHCP client needs to re-initiate a request.
    • When the DHCP server does not receive any response from the DHCP client for a period of time: If address recycling is configured, the server reclaims the corresponding IP address. Otherwise, the server reclaims the IP address when the lease expires, but not when it receives no response in the period.

IP Address Assignment Modes

To meet different client requirements, DHCP provides the following IP address assignment modes:
  • Manual address assignment: An administrator binds fixed IP addresses to specific clients, such as the WWW server, and uses DHCP to assign these IP addresses to the clients.
  • Automatic address assignment: DHCP assigns IP addresses of infinite lease to clients.
  • Dynamic address assignment: DHCP assigns IP addresses with a validity period to clients. After the validity period expires, the clients must re-apply for addresses. This address assignment mode is widely adopted.

IP Address Assignment Sequence

A DHCP server assigns IP addresses to a client in the following sequence:
  • IP address that is in the database of the DHCP server and is statically bound to the MAC address of the client
  • IP address that has previously been assigned to the client, that is, IP address in the requested IP Addr Option of the DHCPDISCOVER message sent by the client
  • IP address that is first found when the DHCP server searches the DHCP address pool for available IP addresses
  • If the DHCP address pool has no available IP address, the DHCP server searches the expired IP addresses and conflicting IP addresses, and then assigns a valid IP address to the client. If all the IP addresses are in use, an error message is reported.

Method of Preventing Repeated IP Address Assignment

To avoid address conflicts, the DHCP server pings the IP address before assigning it to a client.

The ping command checks whether a response to the ping packet is received within the specified period. If no response to the ping packet is received, the DHCP server continues to send ping packets to the IP address until the number of sent ping packets reaches the maximum limit. If there is still no response, this IP address is not in use, and the DHCP server assigns the IP address to a client. (This method is implemented based on standard protocols.)

IP Address Reservation

DHCP supports IP address reservation for clients. The reserved IP addresses must belong to the address pool. If an address in the address pool is reserved, it is no longer assignable. Addresses are usually reserved for specific clients, such as DNS and WWW servers.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >