Example for Configuring the Device as a DHCP Server (Based on the Interface Address Pool)
Networking Requirements
As shown in Figure 3-12, an enterprise plans two network segments for office terminals. The PCs on the network segment 10.1.1.0/24 are fixed office terminals for employees; the network segment 10.1.2.0/24 is used for employees on business trips to temporarily access the network. To facilitate management, the administrator requires that the enterprise terminals automatically obtain IP addresses and the DNS server IP address. (When users want to use domain names for access, the DNS server for domain name resolution needs to be configured.) The PC (Client_1) of the enterprise manager needs to use the fixed IP address 10.1.1.100/24 based on service requirements.
Configuration Roadmap
The configuration roadmap is as follows:
Configure the DHCP server function on the router to dynamically assign IP addresses and the DNS server address to the terminals on the two network segments of the enterprise. The PCs on 10.1.1.0/24 are fixed office terminals for employees with the IP address lease of 30 days, and DHCP Client_1 is assigned with the fixed IP address (10.1.1.100/24) in DHCP static mode. The network segment 10.1.2.0/24 is used for employees on business trips to temporarily access the network, with the IP address lease of 2 days.
Configure the interface link type and VLANs on the Layer 2 switches LSW_1 and LSW_2 to implement Layer 2 communication.
Procedure
- Enable DHCP.
<Huawei> system-view [Huawei] sysname Router [Router] dhcp enable
- Add interfaces to VLANs.
# Add Eth2/0/0 to VLAN 10.
[Router] vlan batch 10 to 11 [Router] interface ethernet 2/0/0 [Router-Ethernet2/0/0] port link-type access [Router-Ethernet2/0/0] port default vlan 10 [Router-Ethernet2/0/0] quit
# Add Eth2/0/1 to VLAN 11.
[Router] interface ethernet 2/0/1 [Router-Ethernet2/0/1] port link-type access [Router-Ethernet2/0/1] port default vlan 11 [Router-Ethernet2/0/1] quit
- Allocate IP addresses to VLANIF interfaces.
# Set an IP address for VLANIF 10.
[Router] interface vlanif 10 [Router-Vlanif10] ip address 10.1.1.1 24 [Router-Vlanif10] quit
# Set an IP address for VLANIF 11.
[Router] interface vlanif 11 [Router-Vlanif11] ip address 10.1.2.1 24 [Router-Vlanif11] quit
- Configure the interface address pool.
# Configure the clients connected to VLANIF 10 to obtain IP addresses and other network parameters from the interface address pool.
[Router] interface vlanif 10 [Router-Vlanif10] dhcp select interface [Router-Vlanif10] dhcp server gateway-list 10.1.1.1 [Router-Vlanif10] dhcp server lease day 30 [Router-Vlanif10] dhcp server domain-name huawei.com [Router-Vlanif10] dhcp server dns-list 10.1.1.2 [Router-Vlanif10] dhcp server excluded-ip-address 10.1.1.2 [Router-Vlanif10] dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc88-b684 [Router-Vlanif10] quit
# Configure the clients connected to VLANIF 11 to obtain IP addresses and other network parameters from the interface address pool.
[Router] interface vlanif 11 [Router-Vlanif11] dhcp select interface [Router-Vlanif11] dhcp server gateway-list 10.1.2.1 [Router-Vlanif11] dhcp server lease day 2 [Router-Vlanif11] dhcp server domain-name huawei.com [Router-Vlanif11] dhcp server dns-list 10.1.1.2 [Router-Vlanif11] quit
- Verify the configuration.
# Run the display ip pool command on the router to view the allocation of the interface address pool. The Used field indicates the number of allocated IP addresses.
[Router] display ip pool interface vlanif10 Pool-name : Vlanif10 Pool-No : 0 Lease : 30 Days 0 Hours 0 Minutes Domain-name : huawei.com DNS-server0 : 10.1.1.2 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: 1 Days 0 Hours 0 Minutes Address Statistic: Total :253 Used :1 Idle :251 Expired :0 Conflict :0 Disable :1 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.254 253 1 251(0) 0 1 -------------------------------------------------------------------------------
[Router] display ip pool interface vlanif11 Pool-name : Vlanif11 Pool-No : 1 Lease : 2 Days 0 Hours 0 Minutes Domain-name : huawei.com DNS-server0 : 10.1.1.2 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: 1 Days 0 Hours 0 Minutes Address Statistic: Total :253 Used :1 Idle :251 Expired :0 Conflict :0 Disable :1 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.2.1 10.1.2.254 253 1 252(0) 0 0 -------------------------------------------------------------------------------
Configuration Files
Router configuration file
# sysname Router # vlan batch 10 to 11 # dhcp enable # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 dhcp select interface dhcp server gateway-list 10.1.1.1 dhcp server excluded-ip-address 10.1.1.2 dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc88-b684 dhcp server lease day 30 hour 0 minute 0 dhcp server dns-list 10.1.1.2 dhcp server domain-name huawei.com # interface Vlanif11 ip address 10.1.2.1 255.255.255.0 dhcp select interface dhcp server gateway-list 10.1.2.1 dhcp server lease day 2 hour 0 minute 0 dhcp server dns-list 10.1.1.2 dhcp server domain-name huawei.com # interface Ethernet2/0/0 port link-type access port default vlan 10 # interface Ethernet2/0/1 port link-type access port default vlan 11 # return