In Figure 1, an enterprise plans two network segments for office terminals: 10.1.1.0/24 for fixed terminals and 10.1.2.0/24 for terminals used by staff on business trips. To facilitate unified management, the enterprise requires terminals to automatically obtain IP addresses and the DNS server IP address from the Switch (if users access the Internet using domain names, a DNS server must be specified). A PC (DHCP Client_1) requires fixed IP address 10.1.1.100/24 to meet service requirements.
The configuration roadmap is as follows:
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dhcp enable
# 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 hybrid [Switch-GigabitEthernet0/0/1] port hybrid pvid vlan 10 [Switch-GigabitEthernet0/0/1] port hybrid untagged 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 hybrid [Switch-GigabitEthernet0/0/2] port hybrid pvid vlan 11 [Switch-GigabitEthernet0/0/2] port hybrid untagged vlan 11 [Switch-GigabitEthernet0/0/2] quit
# Configure an IP address for VLANIF 10.
[Switch] interface vlanif 10 [Switch-Vlanif10] ip address 10.1.1.1 24 [Switch-Vlanif10] quit
# Configure an IP address for VLANIF 11.
[Switch] interface vlanif 11 [Switch-Vlanif11] ip address 10.1.2.1 24 [Switch-Vlanif11] quit
# Configure the clients connected to VLANIF 10 to obtain IP addresses and other network parameters from the address pool on VLANIF 10.
[Switch] interface vlanif 10 [Switch-Vlanif10] dhcp select interface [Switch-Vlanif10] dhcp server gateway-list 10.1.1.1 [Switch-Vlanif10] dhcp server lease day 30 [Switch-Vlanif10] dhcp server domain-name huawei.com [Switch-Vlanif10] dhcp server dns-list 10.1.3.1 [Switch-Vlanif10] dhcp server static-bind ip-address 10.1.1.100 mac-address 286e-d488-b684 [Switch-Vlanif10] quit
# Configure the clients connected to VLANIF 11 to obtain IP addresses and other network parameters from the address pool on VLANIF 11.
[Switch] interface vlanif 11 [Switch-Vlanif11] dhcp select interface [Switch-Vlanif11] dhcp server gateway-list 10.1.2.1 [Switch-Vlanif11] dhcp server lease day 2 [Switch-Vlanif11] dhcp server domain-name huawei.com [Switch-Vlanif11] dhcp server dns-list 10.1.3.1 [Switch-Vlanif11] quit
[Switch] dhcp server database enable
# On the switch, run the display ip pool command to view IP address allocation in address pools. The Used field displays the number of used IP addresses in the address pool. 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 : huawei.com DNS-server0 : 10.1.3.1 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 Disabled :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 : 2 Days 0 Hours 0 Minutes Domain-name : huawei.com DNS-server0 : 10.1.3.1 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 Disabled :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.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
Switch configuration file
# 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 gateway-list 10.1.1.1 dhcp server static-bind ip-address 10.1.1.100 mac-address 286e-d488-b684 dhcp server lease day 30 hour 0 minute 0 dhcp server dns-list 10.1.3.1 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.3.1 dhcp server domain-name huawei.com # interface GigabitEthernet0/0/1 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # interface GigabitEthernet0/0/2 port link-type hybrid port hybrid pvid vlan 11 port hybrid untagged vlan 11 # return