< Home

Example for Configuring a DHCP Client

DHCP Client Overview

A device can function as a DHCP client and dynamically obtain network parameters including the IP address from a DHCP server. This mechanism lowers manual costs, reduces errors, and facilitates unified management.

Configuration Notes

This example applies to:
  • Chassis switches: V200R005 and later versions
  • Fixed switches: V100R006 and later versions

For details about software mappings, visit Hardware Query Tool and search for the desired product model.

Networking Requirements

As shown in Figure 1, Switch_1 functions as the DHCP client to dynamically obtain information including the IP address, DNS server address, and gateway address from the DHCP server (Switch_2).

Figure 1 Networking diagram for configuring a device as the DHCP server

Configuration Roadmap

  1. Configure Switch_1 as the DHCP client to dynamically obtain the IP address from a DHCP server.
  2. Configure Switch_2 as the DHCP server to dynamically allocate network parameters including IP addresses to Switch_1.

Procedure

  1. Configure Switch_1 as the DHCP client.

    # Create VLAN 10, and add GE0/0/1 to VLAN 10.

    <HUAWEI> system-view [HUAWEI] sysname Switch_1
    [Switch_1] vlan 10
    [Switch_1-vlan10] quit
    [Switch_1] interface gigabitethernet 0/0/1
    [Switch_1-GigabitEthernet0/0/1] port link-type trunk
    [Switch_1-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
    [Switch_1-GigabitEthernet0/0/1] quit

    # Enable the DHCP client function on VLANIF 10.

    [Switch_1] interface vlanif 10
    [Switch_1-Vlanif10] ip address dhcp-alloc
    [Switch_1-Vlanif10] quit

  2. Create a global address pool on Switch_2 and set corresponding attributes.
    1. Enable the DHCP service.

      <HUAWEI> system-view
      [HUAWEI] sysname Switch_2
      [Switch_2] dhcp enable

    2. Create VLAN 10, and add GE0/0/1 to VLAN 10.

      [Switch_2] vlan 10
      [Switch_2-vlan10] quit
      [Switch_2] interface gigabitethernet 0/0/1
      [Switch_2-GigabitEthernet0/0/1] port link-type trunk
      [Switch_2-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
      [Switch_2-GigabitEthernet0/0/1] quit

    3. Configure VLANIF 10 to work in global address pool mode.

      [Switch_2] interface vlanif 10
      [Switch_2-Vlanif10] ip address 192.168.1.1 24
      [Switch_2-Vlanif10] dhcp select global
      [Switch_2-Vlanif10] quit

    4. Create an address pool and set corresponding attributes.

      [Switch_2] ip pool pool1
      [Switch_2-ip-pool-pool1] network 192.168.1.0 mask 24
      [Switch_2-ip-pool-pool1] gateway-list 192.168.1.126
      [Switch_2-ip-pool-pool1] dns-list 192.168.1.2
      [Switch_2-ip-pool-pool1] excluded-ip-address 192.168.1.2
      [Switch_2-ip-pool-pool1] quit

  3. Verify the configuration.

    # Run the display this command on VLANIF 10 of Switch_1 to view the DHCP client configuration.

    [Switch_1] interface vlanif 10
    [Switch_1-Vlanif10] display this
    #
    interface Vlanif10
     ip address dhcp-alloc
    #
    return
    [Switch_1-Vlanif10] quit

    # After VLANIF 10 obtains an IP address, run the display dhcp client command on Switch_1 to view the status of the DHCP client on VLANIF 10. The following uses the command output in V200R011C10 as an example.

    [Switch_1] display dhcp client
    DHCP client lease information on interface Vlanif10 :
     Current machine state         : Bound
     Internet address assigned via : DHCP
     Physical address              : 0487-ea01-0506
     IP address                    : 192.168.1.162
     Subnet mask                   : 255.255.255.0
     Gateway ip address            : 192.168.1.126
     DHCP server                   : 192.168.1.1
     Lease obtained at             : 2017-06-23 14:52:40
     Lease expires at              : 2017-06-24 14:52:40
     Lease renews at               : 2017-06-24 02:52:40
     Lease rebinds at              : 2017-06-24 11:52:40
     DNS                           : 192.168.1.2

    # On Switch_2, run the display ip pool name pool1 command to view IP address allocation in the address pool. The Used field displays the number of used IP addresses in the address pool. The following uses the command output in V200R011C10 as an example.

    [Switch_2] display ip pool name pool1
      Pool-name        : pool1
      Pool-No          : 0
      Lease            : 1 Days 0 Hours 0 Minutes
      Domain-name      : -
      DNS-server0      : 192.168.1.2
      NBNS-server0     : -
      Netbios-type     : -
      Position         : Local
      Status           : Unlocked
      Gateway-0        : 192.168.1.126
      Network          : 192.168.1.0
      Mask             : 255.255.255.0
      VPN instance     : --
      Logging          : Disable
      Conflicted address recycle interval: -
      Address Statistic: Total       :253       Used        :1
                         Idle        :251       Expired     :0
                         Conflict    :0         Disabled    :1
    
     -------------------------------------------------------------------------------
      Network section
             Start           End       Total    Used Idle(Expired) Conflict Disabled
     -------------------------------------------------------------------------------
         192.168.1.1   192.168.1.254     253       1        251(0)       0     1
     -------------------------------------------------------------------------------

Configuration Files

  • Switch_1 configuration file

    #
    sysname Switch_1
    #
    vlan batch 10
    #
    interface Vlanif10
     ip address dhcp-alloc
    #
    interface GigabitEthernet0/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    return
  • Switch_2 configuration file

    #
    sysname Switch_2
    #
    vlan batch 10
    #
    dhcp enable
    #
    ip pool pool1
     gateway-list 192.168.1.126
     network 192.168.1.0 mask 255.255.255.0
     excluded-ip-address 192.168.1.2
     dns-list 192.168.1.2
    #
    interface Vlanif10
     ip address 192.168.1.1 255.255.255.0
     dhcp select global
    #
    interface GigabitEthernet0/0/1
     port link-type trunk
     port trunk allow-pass vlan 10
    #
    return
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >