A DHCP relay forwards DHCP packets between the DHCP server and clients. When the DHCP server and clients belong to different network segment, the DHCP relay needs to be configured. For DHCP clients, the DHCP relay is the DHCP server; for the DHCP server, the DHCP relay is a DHCP client.
The DHCP relay function applies to large networks with many sparsely-distributed user gateways. To reduce the maintenance workload, the network administrator does not want to configure the DHCP server function on each aggregation switch (user gateway) and requires that the DHCP server function be configured on a core device or an exclusive DHCP server be deployed in the server area. In this case, the aggregation switches functioning as the user gateways need to be configured with the DHCP relay function to implement exchange of DHCP packets between the DHCP server and clients.
For applicable product models and versions, see Applicable Product Models and Versions.
For details about software mappings, visit Hardware Query Tool and search for the desired product model.
As shown in Figure 1, an enterprise deploys the DHCP server on the core switch. The DHCP server and terminals in the enterprise belong to different network segments. The enterprise requires that the DHCP server should dynamically assign IP addresses to the terminals.
The configuration roadmap is as follows:
Configure the DHCP relay on SwitchA (user gateway) to forward DHCP packets between the terminals and DHCP server.
On SwitchB, configure the DHCP server based on the global address pool so that the DHCP server can assign IP addresses from the global address pool to the terminals.
Use a Huawei S series switch as an example for the DHCP server (SwitchB).
On the LSW, configure the interface link type and VLAN to implement Layer 2 communication.
# Add the interface to the VLAN.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 100 200 [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type trunk [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 200 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type access [SwitchA-GigabitEthernet0/0/2] port default vlan 100 [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface vlanif 200 [SwitchA-Vlanif200] ip address 192.168.20.1 24 [SwitchA-Vlanif200] quit
# Enable the DHCP relay function on the interface.
[SwitchA] dhcp enable //Enable the DHCP service. By default, the service is disabled. [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 10.10.20.1 24 [SwitchA-Vlanif100] dhcp select relay //Enable the DHCP relay function. By default, the function is disabled. [SwitchA-Vlanif100] dhcp relay server-ip 192.168.20.2 //Configure the DHCP server IP address for the DHCP relay agent. [SwitchA-Vlanif100] quit
# Enable the DHCP service. By default, the service is disabled.
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] dhcp enable
# Configure VLANIF 200 to work in global address pool mode.
[SwitchB] vlan 200 [SwitchB-vlan200] quit [SwitchB] interface gigabitethernet 0/0/1 [SwitchB-GigabitEthernet0/0/1] port link-type trunk [SwitchB-GigabitEthernet0/0/1] port trunk allow-pass vlan 200 [SwitchB-GigabitEthernet0/0/1] quit [SwitchB] interface vlanif 200 [SwitchB-Vlanif200] ip address 192.168.20.2 24 [SwitchB-Vlanif200] dhcp select global //Enable the DHCP server function based on the global address pool on the interface. By default, the function is disabled. [SwitchB-Vlanif200] quit
# Create an address pool and configure the attributes. The default lease (one day) is used and does not need to be configured.
[SwitchB] ip pool pool1 [SwitchB-ip-pool-pool1] network 10.10.20.0 mask 24 //Configure the network segment and mask of the global address pool. [SwitchB-ip-pool-pool1] gateway-list 10.10.20.1 //Configure the gateway address assigned to the terminals. [SwitchB-ip-pool-pool1] quit
[SwitchB] ip route-static 10.10.20.0 255.255.255.0 192.168.20.1
# Run the display dhcp relay interface vlanif 100 command on SwitchA to check the DHCP relay configuration.
[SwitchA] display dhcp relay interface vlanif 100 DHCP relay agent running information of interface Vlanif100 : Server IP address [00] : 192.168.20.2 Gateway address in use : 10.10.20.1
# Run the display ip pool command on SwitchB to check the IP address allocation of pool1. For example, the enterprise has 100 terminals. The following uses the command output in V200R011C10 as an example.
[SwitchB] display ip pool name pool1 Pool-name : pool1 Pool-No : 0 Lease : 1 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.10.20.1 Network : 10.10.20.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :1 Idle :252 Expired :0 Conflict :0 Disabled :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.10.20.1 10.10.20.254 253 1 252(0) 0 0 -------------------------------------------------------------------------------
SwitchA configuration file
# sysname SwitchA # vlan batch 100 200 # dhcp enable # interface Vlanif100 ip address 10.10.20.1 255.255.255.0 dhcp select relay dhcp relay server-ip 192.168.20.2 # interface Vlanif200 ip address 192.168.20.1 255.255.255.0 # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 200 # interface GigabitEthernet0/0/2 port link-type access port default vlan 100 # return
SwitchB configuration file
#
sysname SwitchB
#
vlan batch 200
#
dhcp enable
#
ip pool pool1
gateway-list 10.10.20.1
network 10.10.20.0 mask 255.255.255.0
#
interface Vlanif200
ip address 192.168.20.2 255.255.255.0
dhcp select global
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 200
#
ip route-static 10.10.20.0 255.255.255.0 192.168.20.1
#
return
Series |
Product Model |
Software Version |
---|---|---|
S2700 |
S2720-EI |
V200R006C10, V200R009C00, V200R010C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
S2750-EI |
V200R005C00SPC300, V200R006C00, V200R007C00, V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00 |
|
S3700 |
S3700-SI, S3700-EI |
V100R006C05 |
S3700-HI |
V200R001C00 |
|
S5700 |
S5700-LI |
V200R005C00SPC300, V200R006C00, V200R007C00, V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00 |
S5700S-LI |
V200R005C00SPC300, V200R006C00, V200R007C00, V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00 |
|
S5700-SI |
V200R001C00, V200R002C00, V200R003C00, V200R005C00 |
|
S5700-EI |
V200R001(C00&C01), V200R002C00, V200R003C00, V200R005(C00&C01&C02&C03) |
|
S5700-HI |
V200R001(C00&C01), V200R002C00, V200R003C00, V200R005(C00SPC500&C01&C02) |
|
S5710-X-LI |
V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00 |
|
S5710-EI |
V200R001C00, V200R002C00, V200R003C00, V200R005(C00&C02) |
|
S5710-HI |
V200R003C00, V200R005(C00&C02&C03) |
|
S5720-LI, S5720S-LI |
V200R010C00, V200R011C00, V200R011C10, V200R012(C00&C20), V200R013C00, V200R019C00, V200R019C10 |
|
S5720-SI, S5720S-SI |
V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5720I-SI |
V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5720-EI |
V200R007C00, V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5720-HI |
V200R006C00, V200R007(C00&C10), V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5730-HI |
V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5730-SI |
V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5730S-EI |
V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S5731-H |
V200R013C02, V200R019C00, V200R019C10 |
|
S5731-S, S5731S-S |
V200R019C00, V200R019C10 |
|
S5731S-H |
V200R019C00, V200R019C10 |
|
S5732-H |
V200R019C00, V200R019C10 |
|
S5735-L, S5735S-L |
V200R019C00, V200R019C10 |
|
S5735S-L-M |
V200R019C00, V200R019C10 |
|
S5735-S, S5735S-S |
V200R019C00, V200R019C10 |
|
S5700 |
S5735-S-I |
V200R019C10 |
S6700 |
S6700-EI |
V200R001(C00&C01), V200R002C00, V200R003C00, V200R005(C00&C01&C02) |
S6720-LI, S6720S-LI |
V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S6720-SI, S6720S-SI |
V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S6720-EI |
V200R008C00, V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S6720S-EI |
V200R009C00, V200R010C00, V200R011C00, V200R011C10, V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S6720-HI |
V200R012C00, V200R013C00, V200R019C00, V200R019C10 |
|
S6730-H |
V200R013C02, V200R019C00, V200R019C10 |
|
S6730-S, S6730S-S |
V200R019C00, V200R019C10 |
|
S6730S-H |
V200R019C10 |
|
S7700 |
S7703, S7706, S7712 |
V200R001(C00&C01), V200R002C00, V200R003C00, V200R005C00, V200R006C00, V200R007C00, V200R008C00, V200R009C00, V200R010C00, V200R011C10, V200R012C00, V200R013C00, V200R013C02, V200R019C00, V200R019C10 |
S7703 PoE |
V200R013C00, V200R019C00, V200R019C10 |
|
S7706 PoE |
V200R013C00, V200R019C00, V200R019C10 |
|
S9700 |
S9703, S9706, S9712 |
V200R001(C00&C01), V200R002C00, V200R003C00, V200R005C00, V200R006C00, V200R007(C00&C10), V200R008C00, V200R009C00, V200R010C00, V200R011C10, V200R012C00, V200R013C00 |