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.
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.
The configuration roadmap is as follows:
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
# 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
The configuration details are not provided. The DHCP server must meet the following conditions:
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
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