Configuring a DHCP Client

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.

Background

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.

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.

Prerequisites

Before configuring the DHCP client function, complete the following tasks:

Configure another device on the network as a DHCP server. For details, see Configuring a DHCP Server.

Procedure

  1. Run system-view

    The system view is displayed.

  2. (Optional) Run dhcpc option60 redefined option60Value

    The Option60 to be carried in DHCP messages is configured.

  3. (Optional) Run dhcpc unicast-flag enable

    The Bootp flags field value in a DHCP request message is set to 0x0000 (Unicast).

    By default, DHCP request and response messages are broadcast ones. If the client requires the server to respond in unicast mode for security, run the dhcpc unicast-flag enable command to set the Bootp flags field value in a DHCP request message to 0x0000 (Unicast) before enabling the DHCP client function.

  4. Run interface interface-type interface-number

    The view of the interface to be enabled with the DHCP client function is displayed.

  5. Run ip address dhcp-alloc

    The DHCP client function is enabled on the interface.

    After the DHCP client function is enabled, pay attention to the following points:

    • When multiple logical interfaces apply for an IP address from the same DHCP server, configure different MAC addresses for the logical interfaces. Otherwise, address assignment may fail.

    • After the DHCP client function is enabled on an interface, the interface cannot process FORCE RENEW packets any more.
    • When the DHCP client function is enabled on an interface, the dynamic IP address allocated to the DHCP client may conflict with the MAP public address segment. Therefore, avoid IP address conflict or overlapping during network planning.
  6. (Optional) Run dhcp client expected-lease lease-time

    The expected IP address lease time for the DHCP client is configured.

  7. (Optional) Run dhcpc option60 redefined option60Value

    The Option60 to be carried in DHCP messages is configured.

    If the Option60 is configured in both the system view and interface view, the configuration in the interface view takes effect.

  8. Run commit

    The configuration is committed.

Follow-up Procedure

When a DHCP client no longer uses the assigned IP address, run the dhcp release command so that the DHCP client proactively sends a DHCP Release message to the DHCP server to notify the DHCP server of releasing IP address. If this command is run in the system view, the IP addresses requested by all interfaces from the DHCP server are released. If this command is run in the interface view, only the IP address requested by the specific interface is released from the DHCP server.

Verifying the DHCP Client Configuration

  • Run the display dhcp client-info [ interface interface-type interface-number ] command to view status information of a DHCP client.

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