Example for Configuring DHCP Relay

This section provides an example for configuring a DHCP relay agent to forward DHCP messages between the DHCP clients and the DHCP server on different network segments. This configuration is available only on carrier IP devices.

Networking Requirements

As shown in Figure 1, the DHCP clients reside on the network segment 10.100.0.0/16, and the DHCP server resides on the network segment 172.16.0.0/16. To allow the DHCP clients to obtain IP addresses from the DHCP server, configure a DHCP relay agent to forward DHCP messages between the clients and server and configure a route from the DHCP server to the network segment 10.100.0.0.

The network segment of the DHCP client is 10.100.0.0/16. The IP address of the DNS server is 10.100.1.2/16, the IP address of the NetBIOS server is 10.100.1.3/16, and the IP address of the gateway is 10.100.1.1. On the DHCP server, the routing table contains at least one reachable route to network segment 10.100.0.0.

Figure 1 Configuring DHCP relay

Interfaces 1 and 2 in this example represent GE 0/1/0 and GE 0/1/8, respectively.



Configuration Roadmap

The configuration roadmap is as follows:

  1. Configure a DHCP relay agent.
    1. Configure an IP address for GE 0/1/8.
    2. Specify the DHCP server address and enable DHCP relay on GE 0/1/0 and enable DHCP relay on GE 0/1/0.
  2. Configure the DHCP server.
    1. Configure a route from DHCP server that functions as the DHCP server to GE 0/1/0 on DHCP relay.
    2. Configure an IP address for GE 0/1/0.
    3. Configure IP addresses for the DNS server, NetBIOS server, and egress gateway.
    4. Configure an address pool on DHCP server.

Data Preparation

To complete the configuration, you need the following data:

  • IP address of the interface to have DHCP relay enabled

  • IP address of the DHCP server

Procedure

  1. Configure a DHCP relay agent.

    # Configure an IP address for GE 0/1/8.

    <HUAWEI> system-view
    [~HUAWEI] sysname DeviceA
    [*HUAWEI] commit
    [~DeviceA] interface GigabitEthernet 0/1/8
    [~DeviceA-GigabitEthernet0/1/8] ip address 172.16.1.1 255.255.0.0
    [*DeviceA-GigabitEthernet0/1/8] undo shutdown
    [*DeviceA-GigabitEthernet0/1/8] commit
    [~DeviceA-GigabitEthernet0/1/8] quit

    # Specify the DHCP server address and enable DHCP relay on GE 0/1/0.

    [~DeviceA] dhcp enable
    [~DeviceA] interface gigabitethernet 0/1/0
    [*DeviceA-GigabitEthernet0/1/0] ip address 10.100.1.1 255.255.0.0
    [*DeviceA-GigabitEthernet0/1/0] ip relay address 172.16.1.2
    [*DeviceA-GigabitEthernet0/1/0] ip relay giaddr 10.100.20.1
    [*DeviceA-GigabitEthernet0/1/0] dhcp select relay
    [*DeviceA-GigabitEthernet0/1/0] undo shutdown
    [*DeviceA-GigabitEthernet0/1/0] commit
    [~DeviceA-GigabitEthernet0/1/0] quit

  2. Configure the DHCP server.

    The configuration details are not provided. The DHCP server must meet the following conditions:

    • An address pool is configured and the range of IP addresses that can be assigned is specified.
    • A domain name is configured, and the IP addresses of the DNS server, NetBIOS server, and egress gateway are configured.
    • The address pool lease is configured to improve IP address utilization.

  3. Verify the configuration.

    Run the display dhcp relay address command on the DHCP relay device to view configurations of the relay IP address.

    [~DeviceA] display dhcp relay address all
       ** GigabitEthernet0/1/0 DHCP Relay Address  **
              Dhcp Option          Relay Agent IP       Server IP
              *                    10.100.20.1          172.16.1.2

Configuration Files

  • DHCP relay configuration file

    #
    sysname DeviceA
    #
    dhcp enable
    #
    interface GigabitEthernet0/1/0
     undo shutdown
     ip address 10.100.1.1 255.255.0.0
     dhcp select relay
     ip relay address 172.16.1.2
     ip relay giaddr 10.100.20.1
    #
    interface GigabitEthernet 0/1/8
     undo shutdown
     ip address 172.16.1.1 255.255.0.0
    #
    return 
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >