Typical DHCP Configuration
- Example for Configuring the Device as a DHCP Server (Based on the Interface Address Pool)
- Example for Configuring a Device as the DHCP Server (Based on the Global Address Pool)
- Example for Configuring a DHCP Server to Allocate Different Network Parameters from the Global Address Pool to Dynamic and Static Clients
- Example for Configuring the Device as a DHCP Relay (on the Same Network)
- Example for Configuring the Device as a DHCP Relay (Across a GRE Tunnel)
- Example for Configuring a DHCP Client
- Example for Configuring DHCP Servers Based on the Global Address Pool on the Same Network Segment in VRRP Networking
Example for Configuring the Device as a DHCP Server (Based on the Interface Address Pool)
DHCP Server Overview
Users require that all terminals on a network dynamically obtain network parameters such as IP addresses, DNS server IP address, routing information, and gateway information. The users do not need to manually configure the network parameters including terminal IP addresses. In addition, some mobile terminals (for example, mobile phones, tablets, and laptops) should support plug-and-play, without modification on network parameters each time. To meet these requirements, the DHCP server function can be configured on an aggregation-layer user gateway or a core-layer device to assign network parameters such as IP addresses to terminals.
The Dynamic Host Configuration Protocol (DHCP) uses the client/server mode to dynamically configure and uniformly manage network parameters for users. The DHCP server uses an address pool to assign network parameters such as IP addresses to the users. The global address pool or an interface address pool can be used.
The configuration of an interface address pool is simple, which can be used only when the users and DHCP server belong to the same network segment and the server can only assign network parameters to the users on the interface. It is applicable to small networks with a limited number of devices and controllable configuration and maintenance workload. After the DHCP server function based on the interface address pool is configured on the user gateway, the hosts and mobile terminals on the interface can automatically obtain network parameters such as IP addresses, without manual configuration and modification.
Compared with an interface address pool, the global address pool can be applied to large networks. The DHCP server function based on the global address pool should be configured on a core device, or an exclusive DHCP server be used to assign network parameters such as IP addresses. The user gateway only needs to be enabled with the DHCP relay function. For details, see Example for Configuring the Device as a DHCP Relay (on the Same Network).
Configuration Notes
- V200R009C00 and later versions: S2720-EI
- V200R005C00SPC300 and later versions: S2750-EI, S5700-LI, S5700S-LI
- S3700-SI, S3700-EI, S3700-HI
- S5700-SI, S5700-EI, S5700-HI, S5710-X-LI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-111, an enterprise divides two network segments for office terminals: 10.1.1.0/24 for employees with fixed office terminals and 10.1.2.0/24 for employees on business trips to temporarily access the network. The enterprise requires that DHCP be used to assign IP addresses to employees with fixed office terminals and employees on business trips. A PC (DHCP Client_1) requires fixed IP address 10.1.1.100/24 to meet service requirements.
Configuration Roadmap
The configuration roadmap is as follows:
Configure the DHCP server function on the Switch to dynamically assign IP addresses to the terminals on the two network segments. Configure the IP address lease to 30 days for the employees with fixed office terminals on 10.1.1.0/24 and one day for the employees on business trips on 10.1.2.0/24 to temporarily access the network.
Configure the interface link types and VLANs on LSW_1 and LSW_2 to implement Layer 2 communication.
Procedure
- Enable the DHCP service. By default, the service is disabled.
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dhcp enable
- Add interfaces to VLANs.
# Add GE0/0/1 to VLAN 10.
[Switch] vlan batch 10 to 11 [Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] port link-type access [Switch-GigabitEthernet0/0/1] port default vlan 10 [Switch-GigabitEthernet0/0/1] quit
# Add GE0/0/2 to VLAN 11.
[Switch] interface gigabitethernet 0/0/2 [Switch-GigabitEthernet0/0/2] port link-type access [Switch-GigabitEthernet0/0/2] port default vlan 11 [Switch-GigabitEthernet0/0/2] quit
- Configure IP addresses for VLANIF interfaces.
# Configure an IP address for VLANIF 10.
[Switch] interface vlanif 10 [Switch-Vlanif10] ip address 10.1.1.1 24 //Network segment assigned by the enterprise for fixed office terminals [Switch-Vlanif10] quit
# Configure an IP address for VLANIF 11.
[Switch] interface vlanif 11 [Switch-Vlanif11] ip address 10.1.2.1 24 //Network segment assigned by the enterprise for employees on business trips [Switch-Vlanif11] quit
- Configure an interface address pool.
# Configure the terminals connected to VLANIF 10 to obtain IP addresses from the interface address pool.
[Switch] interface vlanif 10 [Switch-Vlanif10] dhcp select interface //Enable the DHCP server function based on the interface address pool on the interface. By default, the function is disabled. [Switch-Vlanif10] dhcp server lease day 30 //The default lease is one day. Modify the lease to 30 days. [Switch-Vlanif10] dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc12-3456 //Allocate a fixed IP address to Client_1. [Switch-Vlanif10] quit
# Configure the terminals connected to VLANIF 11 to obtain IP addresses from the interface address pool. The default lease (one day) is used and does not need to be configured.
[Switch] interface vlanif 11 [Switch-Vlanif11] dhcp select interface //Enable the DHCP server function based on the interface address pool on the interface. By default, the function is disabled. [Switch-Vlanif11] quit
- Enable the device to save DHCP data to the storage device. If a fault occurs on the device, you can run the dhcp server database recover command after the system restarts to restore DHCP data from files on the storage device.
[Switch] dhcp server database enable
- Configure each terminal (using the PC running Windows 7 as an example) to automatically obtain an IP address.
- Right-click Network and choose Properties to display the Network and Sharing Center window.
- Click Local Area Connection to display the Local Area Connection Status window.
- Click Properties to display the Local Area Connection Properties window.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties to display the Internet Protocol Version 4 (TCP/IPv4) Properties window. Select Obtain an IP address automatically, and click OK.
- Verify the configuration.
Run the display ip pool command on the Switch to check the configuration of VLANIF 10 and VLANIF 11. For example, the enterprise has 100 employees with fixed office terminals and 3 employees on business trips.
[Switch] display ip pool interface vlanif10 Pool-name : Vlanif10 Pool-No : 0 Lease : 30 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Interface Status : Unlocked Gateway-0 : 10.1.1.1 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :100 Idle :153 Expired :0 Conflict :0 Disable :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.254 253 100 153(0) 0 0 -------------------------------------------------------------------------------
[Switch] display ip pool interface vlanif11 Pool-name : Vlanif11 Pool-No : 1 Lease : 1 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Interface Status : Unlocked Gateway-0 : 10.1.2.1 Network : 10.1.2.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :3 Idle :250 Expired :0 Conflict :0 Disable :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.2.1 10.1.2.254 253 3 250(0) 0 0 -------------------------------------------------------------------------------
Check IP address information on Client_1 (using Windows 7 operating system). The IP address 10.1.1.100/24 has been assigned to Client_1.
C:\Documents and Settings\Administrator>ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 10.1.1.100 Subnet Mask . . . . . . . . . . . : 255.255.254.0 Default Gateway . . . . . . . . . : 10.1.1.1
Check IP address information another DHCP client (for example, a terminal belonging to the network segment 10.1.1.0/24 and using Windows 7 operating system). An IP address has been assigned.
C:\Documents and Settings\Administrator>ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 10.1.1.51 Subnet Mask . . . . . . . . . . . : 255.255.254.0 Default Gateway . . . . . . . . . : 10.1.1.1
Configuration Files
Configuration file of the Switch
# sysname Switch # vlan batch 10 to 11 # dhcp enable # dhcp server database enable # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 dhcp select interface dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc12-3456 dhcp server lease day 30 hour 0 minute 0 # interface Vlanif11 ip address 10.1.2.1 255.255.255.0 dhcp select interface # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type access port default vlan 11 # return
Example for Configuring a Device as the DHCP Server (Based on the Global Address Pool)
DHCP Server Overview
Users require that all terminals on a network dynamically obtain network parameters such as IP addresses, DNS server IP address, routing information, and gateway information. The users do not need to manually configure the network parameters including terminal IP addresses. In addition, some mobile terminals (for example, mobile phones, tablets, and laptops) should support plug-and-play, without modification on network parameters each time. To meet these requirements, the DHCP server function can be configured on an aggregation-layer user gateway or a core-layer device to assign network parameters such as IP addresses to terminals.
The Dynamic Host Configuration Protocol (DHCP) uses the client/server mode to dynamically configure and uniformly manage network parameters for users. The DHCP server uses an address pool to assign network parameters such as IP addresses to the users. The global address pool or an interface address pool can be used.
The configuration of an interface address pool is simple, which can be used only when the users and DHCP server belong to the same network segment and the server can only assign network parameters to the users on the interface. It is applicable to small networks with a limited number of devices and controllable configuration and maintenance workload. After the DHCP server function based on the interface address pool is configured on the user gateway, the hosts and mobile terminals on the interface can automatically obtain network parameters such as IP addresses, without manual configuration and modification.
Compared with an interface address pool, the global address pool can be applied to large networks. The DHCP server function based on the global address pool should be configured on a core device, or an exclusive DHCP server be used to assign network parameters such as IP addresses. The user gateway only needs to be enabled with the DHCP relay function. For details, see Example for Configuring the Device as a DHCP Relay (on the Same Network).
Configuration Notes
- V200R009C00 and later versions: S2720-EI
- V200R005C00SPC300 and later versions: S2750-EI, S5700-LI, S5700S-LI
- S3700-SI, S3700-EI, S3700-HI
- S5700-SI, S5700-EI, S5700-HI, S5710-X-LI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-112, an enterprise has two offices, to save network resources, the switch functions as the DHCP server to allocate IP addresses to hosts in the two offices. Hosts in office 1 are on the network segment 10.1.1.0/25 and are added to VLAN 10, the lease of IP addresses for these hosts is ten days; hosts in office 2 are on the network segment 10.1.1.128/25 and are added to VLAN 11, the lease of IP addresses for these hosts is two days.
Configuration Roadmap
The configuration roadmap is as follows:
Configure the switch as the DHCP server to dynamically allocate IP addresses and the DNS server address to hosts in the two offices. PCs on the network segment 10.1.1.0/25 are for employees in office 1 and obtain IP addresses with a lease of ten days. PCs on the network segment 10.1.1.128/25 are for employees in office 2 and obtain IP addresses with a lease of two days.
Procedure
- Enable the DHCP service.
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dhcp enable
- Add interfaces to a VLAN.
# Add GE1/0/1 to VLAN 10.
[Switch] vlan batch 10 to 11 [Switch] interface gigabitethernet 1/0/1 [Switch-GigabitEthernet1/0/1] port link-type hybrid [Switch-GigabitEthernet1/0/1] port hybrid pvid vlan 10 [Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 10 [Switch-GigabitEthernet1/0/1] quit
# Add GE1/0/2 to VLAN 11.
[Switch] interface gigabitethernet 1/0/2 [Switch-GigabitEthernet1/0/2] port link-type hybrid [Switch-GigabitEthernet1/0/2] port hybrid pvid vlan 11 [Switch-GigabitEthernet1/0/2] port hybrid untagged vlan 11 [Switch-GigabitEthernet1/0/2] quit
- Configure IP addresses for VLANIF interfaces.
# Configure an IP address for VLANIF 10.
[Switch] interface vlanif 10 [Switch-Vlanif10] ip address 10.1.1.1 25 [Switch-Vlanif10] quit
# Configure an IP address for VLANIF 11.
[Switch] interface vlanif 11 [Switch-Vlanif11] ip address 10.1.1.129 25 [Switch-Vlanif11] quit
- Configure global address pools.
# Configure the IP addresses and relevant network parameters of the global address pool pool1.
[Switch] ip pool pool1 [Switch-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.128 [Switch-ip-pool-pool1] dns-list 10.1.2.3 [Switch-ip-pool-pool1] gateway-list 10.1.1.1 [Switch-ip-pool-pool1] lease day 10 [Switch-ip-pool-pool1] quit
# Configure the IP addresses and relevant network parameters of the global address pool pool2.
[Switch] ip pool pool2 [Switch-ip-pool-pool1] network 10.1.1.128 mask 255.255.255.128 [Switch-ip-pool-pool1] dns-list 10.1.2.3 [Switch-ip-pool-pool1] gateway-list 10.1.1.129 [Switch-ip-pool-pool1] lease day 2 [Switch-ip-pool-pool1] quit
- Enable the DHCP server.
# Enable the DHCP server on VLANIF 10.
[Switch] interface vlanif 10 [Switch-Vlanif10] dhcp select global [Switch-Vlanif10] quit
# Enable the DHCP server on VLANIF 11.
[Switch] interface vlanif 11 [Switch-Vlanif11] dhcp select global [Switch-Vlanif11] quit
- Verify the configuration.
# Run the display ip pool name pool1 command on the switch to view IP address allocation in the global address pool pool1. The Used field displays the number of allocated IP addresses. The following uses the command output in V200R011C10 as an example.
[Switch] display ip pool name pool1 Pool-name : pool1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : 10.1.2.3 NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.1.1.1 Network : 10.1.1.0 Mask : 255.255.255.128 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :125 Used :2 Idle :123 Expired :0 Conflict :0 Disabled :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.126 125 2 123(0) 0 0 -------------------------------------------------------------------------------
# Run the display ip pool name pool2 command on the switch to view IP address allocation in the global address pool pool2. The Used field displays the number of allocated IP addresses. The following uses the command output in V200R011C10 as an example.
[Switch] display ip pool name pool2 Pool-name : pool2 Pool-No : 1 Lease : 2 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : 10.1.2.3 NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.1.1.129 Network : 10.1.1.128 Mask : 255.255.255.128 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :125 Used :2 Idle :123 Expired :0 Conflict :0 Disabled :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.129 10.1.1.254 125 2 123(0) 0 0 -------------------------------------------------------------------------------
Configuration Files
Switch configuration file
# sysname Switch # vlan batch 10 to 11 # dhcp enable # ip pool pool1 gateway-list 10.1.1.1 network 10.1.1.0 mask 255.255.255.128 lease day 10 hour 0 minute 0 dns-list 10.1.2.3 # ip pool pool2 gateway-list 10.1.1.129 network 10.1.1.128 mask 255.255.255.128 lease day 2 hour 0 minute 0 dns-list 10.1.2.3 # interface Vlanif10 ip address 10.1.1.1 255.255.255.128 dhcp select global # interface Vlanif11 ip address 10.1.1.129 255.255.255.128 dhcp select global # interface GigabitEthernet1/0/1 port hybrid pvid vlan 10 port hybrid untagged vlan 10 # interface GigabitEthernet1/0/2 port hybrid pvid vlan 11 port hybrid untagged vlan 11 # return
Example for Configuring a DHCP Server to Allocate Different Network Parameters from the Global Address Pool to Dynamic and Static Clients
DHCP Server Overview
Users require that all terminals on a network dynamically obtain network parameters such as IP addresses, DNS server IP address, routing information, and gateway information. The users do not need to manually configure the network parameters including terminal IP addresses. In addition, some mobile terminals (for example, mobile phones, tablets, and laptops) should support plug-and-play, without modification on network parameters each time. To meet these requirements, the DHCP server function can be configured on an aggregation-layer user gateway or a core-layer device to assign network parameters such as IP addresses to terminals.
The Dynamic Host Configuration Protocol (DHCP) uses the client/server mode to dynamically configure and uniformly manage network parameters for users. The DHCP server uses an address pool to assign network parameters such as IP addresses to the users. The global address pool or an interface address pool can be used.
The configuration of an interface address pool is simple, which can be used only when the users and DHCP server belong to the same network segment and the server can only assign network parameters to the users on the interface. It is applicable to small networks with a limited number of devices and controllable configuration and maintenance workload. After the DHCP server function based on the interface address pool is configured on the user gateway, the hosts and mobile terminals on the interface can automatically obtain network parameters such as IP addresses, without manual configuration and modification.
Compared with an interface address pool, the global address pool can be applied to large networks. The DHCP server function based on the global address pool should be configured on a core device, or an exclusive DHCP server be used to assign network parameters such as IP addresses. The user gateway only needs to be enabled with the DHCP relay function. For details, see Example for Configuring the Device as a DHCP Relay (on the Same Network).
Configuration Notes
- V200R009C00 and later versions: S2720-EI
- V200R005C00SPC300 and later versions: S2750-EI, S5700-LI, S5700S-LI
- S3700-SI, S3700-EI, S3700-HI
- S5700-SI, S5700-EI, S5700-HI, S5710-X-LI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-113, the IP phone and PCs are devices in an office area. To uniformly manage devices and reduce manual configuration costs, the administrator needs to configure hosts to dynamically obtain IP addresses through DHCP. PCs are fixed terminals in the duty room. They need to always be online and use domain names to access network devices. In addition to obtaining an IP address dynamically, the PCs require an unlimited IP address lease and need to obtain information about the DNS server. The IP phone uses a fixed IP address 10.1.1.4/24 and its MAC address is 00e0-fc12-3456. In addition to obtaining an IP address, the IP phone needs to dynamically obtain the startup configuration file. The startup configuration file configuration.ini is stored on the FTP server. The routes between the FTP server and IP phone must be reachable. The gateway address of the PCs and IP phone is 10.1.1.1/24.
Configuration Roadmap
- Create a DHCP Option template on SwitchA. In the DHCP Option template view, configure the startup configuration file for the static client IP phone, and specify the IP address of the FTP server for the IP phone.
- Create a global address pool on SwitchA. In the global address pool view, configure the IP address lease and information about the DNS server for the dynamic client PCs. Bind an IP address and the DHCP Option template to the MAC address of the static client IP phone. In this way, the DHCP server can allocate different network parameters to dynamic and static clients.
Procedure
- Create a VLAN and configure an IP address for the VLANIF interface.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan 10 [SwitchA-vlan10] quit [SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type hybrid [SwitchA-GigabitEthernet1/0/1] port hybrid pvid vlan 10 [SwitchA-GigabitEthernet1/0/1] port hybrid untagged vlan 10 [SwitchA-GigabitEthernet1/0/1] quit [SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 255.255.255.0 [SwitchA-Vlanif10] quit
- Enable the DHCP service.
[SwitchA] dhcp enable
- Create a DHCP Option template. In the DHCP Option template view, configure the startup configuration file for the static client IP phone, and specify the IP address of the file server for the IP phone.
[SwitchA] dhcp option template template1 [SwitchA-dhcp-option-template-template1] gateway-list 10.1.1.1 [SwitchA-dhcp-option-template-template1] bootfile configuration.ini [SwitchA-dhcp-option-template-template1] next-server 10.1.1.3 [SwitchA-dhcp-option-template-template1] quit
- Create an IP address pool. In the IP address pool view, configure the gateway address, IP address lease, and IP address of the DNS server for the PCs. Allocate a fixed IP address to the IP phone and configure the startup configuration file.
[SwitchA] ip pool pool1 [SwitchA-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.0 [SwitchA-ip-pool-pool1] dns-list 10.1.1.2 [SwitchA-ip-pool-pool1] gateway-list 10.1.1.1 [SwitchA-ip-pool-pool1] excluded-ip-address 10.1.1.2 10.1.1.3 [SwitchA-ip-pool-pool1] lease unlimited [SwitchA-ip-pool-pool1] static-bind ip-address 10.1.1.4 mac-address 00e0-fc12-3456 option-template template1 [SwitchA-ip-pool-pool1] quit
- Enable the DHCP server function on the VLANIF 10 interface.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] dhcp select global [SwitchA-Vlanif10] quit
- Enable the device to save DHCP data to the storage device. If a fault occurs on the device, you can run the dhcp server database recover command after the system restarts to restore DHCP data from files on the storage device.
[SwitchA] dhcp server database enable
- Verify the configuration.
# Run the display ip pool name pool1 command on SwitchA to view the address pool configuration. The following uses the command output in V200R011C10 as an example.
[SwitchA] display ip pool name pool1 Pool-name : pool1 Pool-No : 0 Lease : unlimited Domain-name : - DNS-server0 : 10.1.1.2 NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.1.1.1 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :1 Idle :250 Expired :0 Conflict :0 Disabled :2 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.254 253 4 249(0) 0 2 -------------------------------------------------------------------------------
# Run the display dhcp option template name template1 command on SwitchA to view the DHCP Option template configuration.
[SwitchA] display dhcp option template name template1 ----------------------------------------------------------------------------- Template-Name : template1 Template-No : 0 Next-server : 10.1.1.3 Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Gateway-0 : 10.1.1.1 Bootfile : configuration.ini
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # vlan batch 10 # dhcp enable # dhcp server database enable # dhcp option template template1 gateway-list 10.1.1.1 next-server 10.1.1.3 bootfile configuration.ini # ip pool pool1 gateway-list 10.1.1.1 network 10.1.1.0 mask 255.255.255.0 excluded-ip-address 10.1.1.2 10.1.1.3 static-bind ip-address 10.1.1.4 mac-address 00e0-fc12-3456 option-template template1 lease unlimited dns-list 10.1.1.2 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 dhcp select global # interface GigabitEthernet1/0/1 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # return
Example for Configuring the Device as a DHCP Relay (on the Same Network)
DHCP Relay Overview
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.
Configuration Notes
- V200R005C00SPC300 and later versions: S2750-EI, S5700-LI, S5700S-LI
- S2720-EI, S3700-SI, S3700-EI, S3700-HI
- S5700-LI, S5700S-LI, S5700-SI, S5700-EI, S5700-HI, S5710-X-LI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-114, 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.
Configuration Roadmap
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.
Procedure
- Configure the DHCP relay on SwitchA.
# 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
- Configure the DHCP server function based on the global address pool on SwitchB.
# 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
- Configure static routes to the terminals on SwitchB.
[SwitchB] ip route-static 10.10.20.0 255.255.255.0 192.168.20.1
- Configure each terminal (using the PC running Windows 7 as an example) to automatically obtain an IP address.
- Right-click Network and choose Properties to display the Network and Sharing Center window.
- Click Local Area Connection to display the Local Area Connection Status window.
- Click Properties to display the Local Area Connection Properties window.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties to display the Internet Protocol Version 4 (TCP/IPv4) Properties window. Select Obtain an IP address automatically, and click OK.
- Verify the configuration.
# 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 -------------------------------------------------------------------------------
Configuration Files
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
Example for Configuring the Device as a DHCP Relay (Across a GRE Tunnel)
DHCP Relay Overview
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.
The DHCP relay and DHCP server can be deployed across a VPN (such as GRE or MPLS L3VPN) network. A GRE tunnel is used as an example to describe how to configure a DHCP relay.
Configuration Notes
- S5710-EI, S5720-EI, S5700-HI, S5710-HI, S5720-HI, S5730-HI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H
- S6700-EI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-115, an enterprise deploys its headquarters and branch in different areas. A GRE tunnel is deployed between the headquarters and branch to enable them to communicate. To facilitate unified management, the enterprise administrator deploys the DHCP server on Switch_1 in the headquarters to assign IP addresses to the terminals in the headquarters and branch. The network segments 10.1.1.0/24 and 10.2.1.0/24 are planned for the headquarters and branch respectively.
Configuration Roadmap
The configuration roadmap is as follows:
Run OSPF between Switch_1, Switch_2, and Switch_3 to ensure the communication between devices.
On Switch_1 and Switch_3, configure tunnel interfaces and create a GRE tunnel.
On Switch_1, 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 in the headquarters and branch.
On Switch_3, configure the DHCP relay function to function as the branch's gateway to forward DHCP packets between the terminals and DHCP servers so that the terminals can apply to the DHCP server for IP addresses.
Use a Huawei S series switch as an example for the DHCP server (Switch_1).
Configure the interface link types and VLANs on LSW_1 and LSW_2 to implement Layer 2 communication.
Procedure
- Configure an IP address for each physical interface on Switch_1 through Switch_3.
# Configure Switch_1.
<HUAWEI> system-view [HUAWEI] sysname Switch_1 [Switch_1] vlan batch 10 30 [Switch_1] interface gigabitethernet 1/0/0 [Switch_1-GigabitEthernet1/0/0] port link-type trunk [Switch_1-GigabitEthernet1/0/0] port trunk allow-pass vlan 10 [Switch_1-GigabitEthernet1/0/0] quit [Switch_1] interface gigabitethernet 2/0/0 [Switch_1-GigabitEthernet2/0/0] port link-type trunk [Switch_1-GigabitEthernet2/0/0] port trunk allow-pass vlan 30 [Switch_1-GigabitEthernet2/0/0] quit [Switch_1] interface vlanif 10 [Switch_1-Vlanif10] ip address 10.20.1.1 24 [Switch_1-Vlanif10] quit [Switch_1] interface vlanif 30 [Switch_1-Vlanif30] ip address 10.1.1.1 24 [Switch_1-Vlanif30] quit
# Configure Switch_2.
<HUAWEI> system-view [HUAWEI] sysname Switch_2 [Switch_2] vlan batch 10 20 [Switch_2] interface gigabitethernet 1/0/0 [Switch_2-GigabitEthernet1/0/0] port link-type trunk [Switch_2-GigabitEthernet1/0/0] port trunk allow-pass vlan 10 [Switch_2-GigabitEthernet1/0/0] quit [Switch_2] interface gigabitethernet 2/0/0 [Switch_2-GigabitEthernet2/0/0] port link-type trunk [Switch_2-GigabitEthernet2/0/0] port trunk allow-pass vlan 20 [Switch_2-GigabitEthernet2/0/0] quit [Switch_2] interface vlanif 10 [Switch_2-Vlanif10] ip address 10.20.1.2 24 [Switch_2-Vlanif10] quit [Switch_2] interface vlanif 20 [Switch_2-Vlanif20] ip address 10.30.1.1 24 [Switch_2-Vlanif20] quit
# Configure Switch_3.
<HUAWEI> system-view [HUAWEI] sysname Switch_3 [Switch_3] vlan batch 20 30 [Switch_3] interface gigabitethernet 1/0/0 [Switch_3-GigabitEthernet1/0/0] port link-type trunk [Switch_3-GigabitEthernet1/0/0] port trunk allow-pass vlan 20 [Switch_3-GigabitEthernet1/0/0] quit [Switch_3] interface gigabitethernet 2/0/0 [Switch_3-GigabitEthernet2/0/0] port link-type trunk [Switch_3-GigabitEthernet2/0/0] port trunk allow-pass vlan 30 [Switch_3-GigabitEthernet2/0/0] quit [Switch_3] interface vlanif 20 [Switch_3-Vlanif20] ip address 10.30.1.2 24 [Switch_3-Vlanif20] quit [Switch_3] interface vlanif 30 [Switch_3-Vlanif30] ip address 10.2.1.1 24 [Switch_3-Vlanif30] quit
- Run OSPF between Switch_1, Switch_2, and Switch_3.
# Configure Switch_1.
[Switch_1] ospf 1 [Switch_1-ospf-1] area 0 [Switch_1-ospf-1-area-0.0.0.0] network 10.20.1.0 0.0.0.255 [Switch_1-ospf-1-area-0.0.0.0] quit [Switch_1-ospf-1] quit
# Configure Switch_2.
[Switch_2] ospf 1 [Switch_2-ospf-1] area 0 [Switch_2-ospf-1-area-0.0.0.0] network 10.20.1.0 0.0.0.255 [Switch_2-ospf-1-area-0.0.0.0] network 10.30.1.0 0.0.0.255 [Switch_2-ospf-1-area-0.0.0.0] quit [Switch_2-ospf-1] quit
# Configure Switch_3.
[Switch_3] ospf 1 [Switch_3-ospf-1] area 0 [Switch_3-ospf-1-area-0.0.0.0] network 10.30.1.0 0.0.0.255 [Switch_3-ospf-1-area-0.0.0.0] quit [Switch_3-ospf-1] quit
- Configure static routes.# Configure a static route to the network segment on Switch_1.
[Switch_1] ip route-static 10.2.1.0 255.255.255.0 tunnel 1
# Configure a static route to the server segment on Switch_3.[Switch_3] ip route-static 10.1.1.0 255.255.255.0 tunnel 1
- Configure tunnel interfaces.
# Configure Switch_1.
[Switch_1] interface tunnel 1 [Switch_1-Tunnel1] tunnel-protocol gre [Switch_1-Tunnel1] ip address 10.40.1.1 24 [Switch_1-Tunnel1] source 10.20.1.1 [Switch_1-Tunnel1] destination 10.30.1.2 [Switch_1-Tunnel1] quit
# Configure Switch_3.
[Switch_3] interface tunnel 1 [Switch_3-Tunnel1] tunnel-protocol gre [Switch_3-Tunnel1] ip address 10.40.1.2 24 [Switch_3-Tunnel1] source 10.30.1.2 [Switch_3-Tunnel1] destination 10.20.1.1 [Switch_3-Tunnel1] quit
- Configure the DHCP server function on Switch_1.
# Enable the DHCP service. By default, the service is disabled.
[Switch_1] dhcp enable
# Create a global address pool and configure related parameters.
[Switch_1] ip pool pool1 [Switch_1-ip-pool-pool1] network 10.2.1.0 mask 255.255.255.0 //Network segment for terminals in the branch [Switch_1-ip-pool-pool1] gateway-list 10.2.1.1 //Gateway address for terminals in the branch [Switch_1-ip-pool-pool1] quit [Switch_1] ip pool pool2 [Switch_1-ip-pool-pool2] network 10.1.1.0 mask 255.255.255.0 //Network segment for terminals in the headquarters [Switch_1-ip-pool-pool2] gateway-list 10.1.1.1 //Gateway address for terminals in the headquarters [Switch_1-ip-pool-pool2] quit
# Configure the terminals connected to VLANIF30 to obtain IP addresses from the global address pool.[Switch_1] interface vlanif 30 [Switch_1-Vlanif30] dhcp select global //Enable the DHCP server function based on the global address pool on the interface. By default, the function is disabled. [Switch_1-Vlanif30] quit
- # Configure the DHCP relay function on Switch_3.
# Enable the DHCP service. By default, the service is disabled.
[Switch_3] dhcp enable
# Configure the DHCP relay function on VLANIF 30 and specifies the DHCP server address for the relay.[Switch_3] interface vlanif 30 [Switch_3-Vlanif30] dhcp select relay //Enable the DHCP relay function. By default, the function is disabled. [Switch_3-Vlanif30] dhcp relay server-ip 10.1.1.1 //Configure the DHCP server IP address for the DHCP relay agent. [Switch_3-Vlanif30] quit
- Configure each terminal (using the PC running Windows 7 as an example) to automatically obtain an IP address.
- Right-click Network and choose Properties to display the Network and Sharing Center window.
- Click Local Area Connection to display the Local Area Connection Status window.
- Click Properties to display the Local Area Connection Properties window.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties to display the Internet Protocol Version 4 (TCP/IPv4) Properties window. Select Obtain an IP address automatically, and click OK.
- Verify the configuration. The following uses the command output in V200R010C00 as an example.
# Run the display dhcp relay interface vlanif 30 command on Switch_3 to check the DHCP relay configuration.
[Switch_3] display dhcp relay interface vlanif 30 DHCP relay agent running information of interface Vlanif30 : Server IP address [00] : 10.1.1.1 Gateway address in use : 10.2.1.1
# Run the display ip pool command on Switch_1 to check the IP address allocation of pool1 and pool2. For example, the headquarters has 100 terminals and the branch has 50 terminals.
[Switch_1] 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.2.1.1 Network : 10.2.1.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :50 Idle :203 Expired :0 Conflict :0 Disable :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.2.1.1 10.2.1.254 253 50 203(0) 0 0 -------------------------------------------------------------------------------
[Switch_1] display ip pool name pool2 Pool-name : pool2 Pool-No : 1 Lease : 1 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.1.1.1 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :50 Idle :203 Expired :0 Conflict :0 Disable :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.254 253 100 153(0) 0 0 -------------------------------------------------------------------------------
Configuration Files
Configuration file of Switch_1
# sysname Switch_1 # vlan batch 10 30 # dhcp enable # ip pool pool1 gateway-list 10.2.1.1 network 10.2.1.0 mask 255.255.255.0 # ip pool pool2 gateway-list 10.1.1.1 network 10.1.1.0 mask 255.255.255.0 # interface Vlanif10 ip address 10.20.1.1 255.255.255.0 # interface Vlanif30 ip address 10.1.1.1 255.255.255.0 dhcp select global # interface GigabitEthernet1/0/0 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet2/0/0 port link-type trunk port trunk allow-pass vlan 30 # interface Tunnel1 ip address 10.40.1.1 255.255.255.0 tunnel-protocol gre source 10.20.1.1 destination 10.30.1.2 # ospf 1 area 0.0.0.0 network 10.20.1.0 0.0.0.255 # ip route-static 10.2.1.0 255.255.255.0 Tunnel1 # return
Configuration file of Switch_2
# sysname Switch_2 # vlan batch 10 20 # interface Vlanif10 ip address 10.20.1.2 255.255.255.0 # interface Vlanif20 ip address 10.30.1.1 255.255.255.0 # interface GigabitEthernet1/0/0 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet2/0/0 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 area 0.0.0.0 network 10.20.1.0 0.0.0.255 network 10.30.1.0 0.0.0.255 # return
Configuration file of Switch_3
# sysname Switch_3 # vlan batch 20 30 # dhcp enable # interface Vlanif20 ip address 10.30.1.2 255.255.255.0 # interface Vlanif30 ip address 10.2.1.1 255.255.255.0 dhcp select relay dhcp relay server-ip 10.1.1.1 # interface GigabitEthernet1/0/0 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet2/0/0 port link-type trunk port trunk allow-pass vlan 30 # interface Tunnel1 ip address 10.40.1.2 255.255.255.0 tunnel-protocol gre source 10.30.1.2 destination 10.20.1.1 # ospf 1 area 0.0.0.0 network 10.30.1.0 0.0.0.255 # ip route-static 10.1.1.0 255.255.255.0 Tunnel1 # return
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
- Chassis switches: V200R005 and later versions
- Fixed switches: V100R006 and later versions
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-116, 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).
Configuration Roadmap
- Configure Switch_1 as the DHCP client to dynamically obtain the IP address from a DHCP server.
- Configure Switch_2 as the DHCP server to dynamically allocate network parameters including IP addresses to Switch_1.
Procedure
- Configure Switch_1 as the DHCP client.
# Create VLAN 10, and add GE1/0/1 to VLAN 10.
<HUAWEI> system-view [HUAWEI] sysname Switch_1 [Switch_1] vlan 10 [Switch_1-vlan10] quit [Switch_1] interface gigabitethernet 1/0/1 [Switch_1-GigabitEthernet1/0/1] port link-type trunk [Switch_1-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 [Switch_1-GigabitEthernet1/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
- Create a global address pool on Switch_2 and set corresponding attributes.
- 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 : xxxx-xxxx-xxxx 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 GigabitEthernet1/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 GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # return
Example for Configuring DHCP Servers Based on the Global Address Pool on the Same Network Segment in VRRP Networking
DHCP Server Overview
Users require that all terminals on a network dynamically obtain network parameters such as IP addresses, DNS server IP address, routing information, and gateway information. The users do not need to manually configure the network parameters including terminal IP addresses. In addition, some mobile terminals (for example, mobile phones, tablets, and laptops) should support plug-and-play, without modification on network parameters each time. To meet these requirements, the DHCP server function can be configured on an aggregation-layer user gateway or a core-layer device to assign network parameters such as IP addresses to terminals.
The Dynamic Host Configuration Protocol (DHCP) uses the client/server mode to dynamically configure and uniformly manage network parameters for users. The DHCP server uses an address pool to assign network parameters such as IP addresses to the users. The global address pool or an interface address pool can be used.
The configuration of an interface address pool is simple, which can be used only when the users and DHCP server belong to the same network segment and the server can only assign network parameters to the users on the interface. It is applicable to small networks with a limited number of devices and controllable configuration and maintenance workload. After the DHCP server function based on the interface address pool is configured on the user gateway, the hosts and mobile terminals on the interface can automatically obtain network parameters such as IP addresses, without manual configuration and modification.
Compared with an interface address pool, the global address pool can be applied to large networks. The DHCP server function based on the global address pool should be configured on a core device, or an exclusive DHCP server be used to assign network parameters such as IP addresses. The user gateway only needs to be enabled with the DHCP relay function. For details, see Example for Configuring the Device as a DHCP Relay (on the Same Network).
Configuration Notes
- V200R011C10 and later versions: S2720-EI
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S500, S5735-S, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-117, a host in an enterprise is dual-homed to SwitchA and SwitchB through Switch. SwitchA functions as the master DHCP server to allocate IP addresses to the host. If the master DHCP server fails, a backup DHCP server must allocate an IP address to the host.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure IP addresses for interfaces connecting SwitchA and SwitchB to implement network-layer connectivity. Configure Switch to transparently transmit Layer 2 packets.
- Configure a VRRP group on SwitchA and SwitchB. SwitchA has a higher priority and functions as the DHCP server to allocate IP addresses to clients. SwitchB has a lower priority and functions as a backup DHCP server.
- Create global address pools on SwitchA and SwitchB, and set corresponding attributes.
- Configure a loop prevention protocol on Switch, SwitchA, and SwitchB to prevent loops. In this example, STP is configured.
Procedure
- Configure network-layer connectivity among devices.
# Configure IP addresses for interfaces connecting SwitchA and SwitchB. SwitchA is used as an example. The configuration on SwitchB is similar to that on SwitchA. For details, see the configuration file of SwitchB.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 100 [SwitchA] interface gigabitethernet 1/0/2 [SwitchA-GigabitEthernet1/0/2] port link-type hybrid [SwitchA-GigabitEthernet1/0/2] port hybrid pvid vlan 100 [SwitchA-GigabitEthernet1/0/2] port hybrid untagged vlan 100 [SwitchA-GigabitEthernet1/0/2] quit [SwitchA] interface gigabitethernet 1/0/5 [SwitchA-GigabitEthernet1/0/5] port link-type hybrid [SwitchA-GigabitEthernet1/0/5] port hybrid pvid vlan 100 [SwitchA-GigabitEthernet1/0/5] port hybrid untagged vlan 100 [SwitchA-GigabitEthernet1/0/5] quit [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 10.1.1.1 24 [SwitchA-Vlanif100] quit
# Configure Layer 2 transparent transmission on Switch.
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] vlan 100 [Switch-vlan100] quit [Switch] interface gigabitethernet 1/0/1 [Switch-GigabitEthernet1/0/1] port link-type hybrid [Switch-GigabitEthernet1/0/1] port hybrid pvid vlan 100 [Switch-GigabitEthernet1/0/1] port hybrid untagged vlan 100 [Switch-GigabitEthernet1/0/1] quit [Switch] interface gigabitethernet 1/0/2 [Switch-GigabitEthernet1/0/2] port link-type hybrid [Switch-GigabitEthernet1/0/2] port hybrid pvid vlan 100 [Switch-GigabitEthernet1/0/2] port hybrid untagged vlan 100 [Switch-GigabitEthernet1/0/2] quit [Switch] interface gigabitethernet 1/0/3 [Switch-GigabitEthernet1/0/3] port link-type access [Switch-GigabitEthernet1/0/3] port default vlan 100 [Switch-GigabitEthernet1/0/3] quit
- Create address pools and set corresponding attributes.
# Enable DHCP on SwitchA.
[SwitchA] dhcp enable
# Create an address pool on SwitchA and specify an IP address range 10.1.1.2 to 10.1.1.128, which is exclusive from the IP address range of the address pool on SwitchB.
Information about the address pool on the master DHCP server cannot be backed up to a backup DHCP server in real time. To prevent IP address conflicts after a master/backup switchover, ensure that the address pool ranges on the master and backup DHCP servers are exclusive to one another.
[SwitchA] ip pool 1 [SwitchA-ip-pool-1] network 10.1.1.0 mask 255.255.255.0 [SwitchA-ip-pool-1] gateway-list 10.1.1.111 [SwitchA-ip-pool-1] excluded-ip-address 10.1.1.1 [SwitchA-ip-pool-1] excluded-ip-address 10.1.1.129 10.1.1.254 [SwitchA-ip-pool-1] lease day 10 [SwitchA-ip-pool-1] quit
# Create an address pool on SwitchB and specify an IP address range 10.1.1.130 to 10.1.1.254, which is exclusive from the IP address range of the address pool on SwitchA.
[SwitchB] dhcp enable [SwitchB] ip pool 1 [SwitchB-ip-pool-1] network 10.1.1.0 mask 255.255.255.0 [SwitchB-ip-pool-1] gateway-list 10.1.1.111 [SwitchB-ip-pool-1] excluded-ip-address 10.1.1.1 10.1.1.110 [SwitchB-ip-pool-1] excluded-ip-address 10.1.1.112 10.1.1.129 [SwitchB-ip-pool-1] lease day 10 [SwitchB-ip-pool-1] quit
- Configure a VRRP group.
# Create VRRP group 1 on SwitchA, set the priority of SwitchA in the VRRP group to 120, and configure clients to obtain IP addresses from a global address pool.
[SwitchA] interface vlanif 100 [SwitchA-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111 [SwitchA-Vlanif100] vrrp vrid 1 priority 120 [SwitchA-Vlanif100] dhcp select global [SwitchA-Vlanif100] quit
# Create VRRP group 1 on SwitchB, set the priority of SwitchB in the VRRP group to 100 (default), and configure clients to obtain IP addresses from a global address pool.
[SwitchB] interface vlanif 100 [SwitchB-Vlanif100] vrrp vrid 1 virtual-ip 10.1.1.111 [SwitchB-Vlanif100] dhcp select global [SwitchB-Vlanif100] quit
- Configure STP to prevent loops.
# Enable STP globally on Switch. The configurations on SwitchA and SwitchB are similar to that on Switch. For details, see the configuration files of SwitchA and SwitchB.
[Switch] stp enable
# Disable STP on GE1/0/3 of Switch, and set the path cost of GE1/0/1 to 20000.
[Switch] interface gigabitethernet 1/0/3 [Switch-GigabitEthernet1/0/3] stp disable [Switch-GigabitEthernet1/0/3] quit [Switch] interface gigabitethernet 1/0/1 [Switch-GigabitEthernet1/0/1] stp cost 20000 [Switch-GigabitEthernet1/0/1] quit
- Verify the configuration.
# Run the display vrrp command on SwitchA and SwitchB. The command output shows that SwitchA is Master and SwitchB is Backup in the VRRP group.
[SwitchA] display vrrp Vlanif100 | Virtual Router 1 State : Master Virtual IP : 10.1.1.111 Master IP : 10.1.1.1 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 120 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2017-01-12 20:15:46 Last change time : 2017-01-12 20:15:46
[SwitchB] display vrrp Vlanif100 | Virtual Router 1 State : Backup Virtual IP : 10.1.1.111 Master IP : 10.1.1.1 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 120 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2017-01-12 20:15:46 Last change time : 2017-01-12 20:15:46
# Run the display ip pool command on SwitchA and SwitchB. The command output shows that SwitchA, but not SwitchB, successfully allocated an IP address to the client. The following uses the command output in V200R011C10 as an example.
[SwitchA] display ip pool ------------------------------------------------------------------------------- Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Conflicted address recycle interval: - Address Statistic: Total :253 Used :1 Idle :125 Expired :0 Conflict :0 Disable :127 IP address Statistic Total :253 Used :1 Idle :125 Expired :0 Conflict :0 Disable :127
[SwitchB] display ip pool ------------------------------------------------------------------------------- Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Conflicted address recycle interval: - Address Statistic: Total :253 Used :0 Idle :125 Expired :0 Conflict :0 Disable :128 IP address Statistic Total :253 Used :0 Idle :125 Expired :0 Conflict :0 Disable :128
# Run the shutdown command on GE1/0/2 and GE1/0/5 of SwitchA to simulate a fault.
[SwitchA] interface gigabitethernet 1/0/2 [SwitchA-GigabitEthernet1/0/2] shutdown [SwitchA-GigabitEthernet1/0/2] quit [SwitchA] interface gigabitethernet 1/0/5 [SwitchA-GigabitEthernet1/0/5] shutdown [SwitchA-GigabitEthernet1/0/5] quit
# Run the display vrrp command on SwitchA and SwitchB. The command output shows that SwitchA is Initialize and SwitchB is Master in the VRRP group.
[SwitchA] display vrrp Vlanif100 | Virtual Router 1 State : Initialize Virtual IP : 10.1.1.111 Master IP : 0.0.0.0 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 0 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2017-01-12 20:15:46 Last change time : 2017-01-12 20:15:46
[SwitchB] display vrrp Vlanif100 | Virtual Router 1 State : Master Virtual IP : 10.1.1.111 Master IP : 10.1.1.129 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 100 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2017-01-12 20:15:46 Last change time : 2017-01-12 20:15:46
# Run the display ip pool command on SwitchB to view the address pool configuration.
[SwitchB] display ip pool Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Conflicted address recycle interval: - Address Statistic: Total :253 Used :1 Idle :124 Expired :0 Conflict :0 Disabled :128 IP address Statistic Total :253 Used :1 Idle :124 Expired :0 Conflict :0 Disabled :128
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # vlan batch 100 # dhcp enable # ip pool 1 gateway-list 10.1.1.111 network 10.1.1.0 mask 255.255.255.0 excluded-ip-address 10.1.1.1 excluded-ip-address 10.1.1.129 10.1.1.254 lease day 10 hour 0 minute 0 # interface Vlanif100 ip address 10.1.1.1 255.255.255.0 vrrp vrid 1 virtual-ip 10.1.1.111 vrrp vrid 1 priority 120 dhcp select global # interface GigabitEthernet1/0/2 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # interface GigabitEthernet1/0/5 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # return
Configuration file of SwitchB
# sysname SwitchB # vlan batch 100 # dhcp enable # ip pool 1 gateway-list 10.1.1.111 network 10.1.1.0 mask 255.255.255.0 excluded-ip-address 10.1.1.1 10.1.1.110 excluded-ip-address 10.1.1.112 10.1.1.129 lease day 10 hour 0 minute 0 # interface Vlanif100 ip address 10.1.1.129 255.255.255.0 vrrp vrid 1 virtual-ip 10.1.1.111 dhcp select global # interface GigabitEthernet1/0/2 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # interface GigabitEthernet1/0/5 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # return
Configuration file of Switch
# sysname Switch # vlan batch 100 # interface GigabitEthernet1/0/1 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 stp instance 0 cost 20000 # interface GigabitEthernet1/0/2 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # interface GigabitEthernet1/0/3 port link-type access port default vlan 100 stp disable # return
- Example for Configuring the Device as a DHCP Server (Based on the Interface Address Pool)
- Example for Configuring a Device as the DHCP Server (Based on the Global Address Pool)
- Example for Configuring a DHCP Server to Allocate Different Network Parameters from the Global Address Pool to Dynamic and Static Clients
- Example for Configuring the Device as a DHCP Relay (on the Same Network)
- Example for Configuring the Device as a DHCP Relay (Across a GRE Tunnel)
- Example for Configuring a DHCP Client
- Example for Configuring DHCP Servers Based on the Global Address Pool on the Same Network Segment in VRRP Networking