Configuring DHCP Relay

After a DHCP relay agent is configured, it can forward DHCP Request messages from DHCP clients to the DHCP server on a different network segment.

Context

If the DHCP clients and DHCP server reside on different network segments, configure DHCP relay on an interface to forward DHCP Request messages from the DHCP clients to the DHCP server so that the clients can dynamically obtain IP addresses from the DHCP server.

If the DHCP relay has multiple clients, and multiple interfaces on the DHCP relay function as gateways, each gateway uses a public IP address, which wastes resources. If the relay interface on a router uses an unnumbered address as the gateway address, public IP address resources will be greatly saved.

If a relay interface uses an unnumbered IP address, the DHCP relay performs the following operations to ensure DHCP packet forwarding:
  • The DHCP relay generates a user table for the users who go online from the relay interface and saves information, such as users' MAC addresses, online interface, and belonging VLAN.
  • Upon receipt of a response packet from the server, the DHCP relay searches the user table based on the chaddr field for the corresponding online interface and forwards the response packet from this interface.
In addition, the DHCP relay generates two entries after a response packet is received from the server.
  • ARP entry used to notify the ARP module of adding online users
  • Entry used to notify the route management module of delivering the user's host routes
In this way, when forwarding network-to-user traffic, the DHCP relay agent can find host routes based on the destination IP addresses (IP addresses assigned to users) and locate the outbound interfaces (user access interfaces) for DHCP response packets. Based on the ARP entries, the relay agent can obtain the MAC addresses of users.

Procedure

  • Configure basic DHCP relay functions on a common interface.
    1. Run system-view

      The system view is displayed.

    2. Run dhcp enable

      DHCP is enabled globally.

    3. (Optional) Run dhcp-server packet-distribute giaddr

      The relay device is enabled to forward reply packets based on the GIADDR field value.

      In a scenario where a DHCP client applies for IP addresses from the DHCP server through a relay device, if the DHCP client uses the same MAC address but different sub-interfaces to request for IP addresses in different network segments through the BRAS and DHCP relay, the relay device may send return packets to the BAS user upon receipt of DHCP reply packets from the DHCP server. This is because the MAC address of the BRAS is the same as that of the DHCP relay. As a result, the DHCP relay user fails to go online. To address this problem, run the dhcp-server packet-distribute giaddr command to enable a relay device to determine whether to forward the reply packets sent by the DHCP server to the BAS user or DHCP relay user based on the GIADDR field value.

    4. Run interface interface-type interface-number

      The interface view is displayed.

    5. Run ip address ip-address { mask | mask-length }

      The primary IP address is configured for the interface.

    6. (Optional) Run ip address ip-address { mask | mask-length } sub

      The secondary IP address is configured for the interface.

    7. Run dhcp select relay

      DHCP relay is enabled on the interface.

    8. Run ip relay address ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP server address is associated with the relay interface based on a DHCP option or Option 60.

    9. (Optional) Run ip relay giaddr ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP relay gateway address is configured for the interface.

    10. (Optional) Run dhcp relay source-ip-address ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP relay source IP address is configured for the interface.

    11. Run quit

      Return to the system view.

    12. (Optional) Run dhcp rate-limit { disable | rateLimitValue }

      Global rate limiting is disabled for DHCP messages or a rate limit is configured for DHCP messages.

    13. Run commit

      The configuration is committed.

  • Configure basic DHCP relay functions on an unnumbered interface.
    1. Run system-view

      The system view is displayed.

    2. Run dhcp enable

      DHCP is enabled globally.

    3. Run interface interface-type interface-number

      The interface view of unnumbered address is displayed.

      Currently, an unnumbered address interface can be an Ethernet physical interface, Ethernet physical sub-interface, VLANIF interface, and Ethernet trunk sub-interface.

    4. Run ip address ip-address { mask | mask-length }

      The primary IP address of the interface is configured.

    5. Run quit

      Return to the system view.

    6. Run interface interface-type interface-number

      The interface view in which DHCP relay is to be enabled is displayed.

    7. Run ip address unnumbered interface interface-type interface-number

      The unnumbered IP address of the relay interface is configured.

      The interface interface-type interface-number parameter must be the same as the interface of the unnumbered address specified in Step 3.

    8. Run dhcp select relay

      DHCP relay is enabled on the interface.

    9. Run ip relay address ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP server address is associated with the relay interface based on a DHCP option or Option 60.

    10. (Optional) Run ip relay giaddr ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP relay gateway address is configured for the interface.

    11. (Optional) Run dhcp relay source-ip-address ip-address [ dhcp-option { code_60 [ option-text ] | code_1to59 | code_61to254 } ]

      A DHCP relay source IP address is configured for the interface.

    12. (Optional) Run dhcp option82 subscriber-id insert enable self-define self-define-value

      The function to insert the Option 82 Subscriber-ID into DHCP request packets is enabled.

    13. Run quit

      Return to the system view.

    14. (Optional) Run dhcp rate-limit { disable | rateLimitValue }

      Global rate limiting is disabled for DHCP messages or a rate limit is configured for DHCP messages.

    15. (Optional) Run dhcp relay arp user-detect interval interval

      The ARP probe time for the DHCP relay user table is configured.

    16. (Optional) Perform the following steps as required:

    17. Run commit

      The configuration is committed.

Follow-up Procedure

  • (Optional) Run dhcp dscp-outbound dscp

    The differentiated services code point (DSCP) value is set for DHCP messages.

  • (Optional) Run dhcp ip-ttl ttl-value

    The time to live (TTL) value is set for DHCP messages.

  • (Optional) Run dhcp relay reply broadcast-always

    The DHCP relay is enabled to broadcast response packets upon receipt of client requests.

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