组网需求
如图1所示,某企业有两个办公室,为了节省资源,两个办公室内的主机由Switch作为DHCP服务器统一分配IP地址。办公室1所属的网段为10.1.1.0/25,主机都加入VLAN10,地址租期为10天;办公室2所属的网段为10.1.1.128/25,主机都加入VLAN11,地址租期为2天。
配置思路
基于全局地址池的DHCP服务器的配置思路如下:
通过在Switch上配置DHCP服务器,实现为企业的两个办公室内终端动态分配IP地址和DNS服务器地址。其中,网段10.1.1.0/25内PC为办公室1员工办公终端,IP地址租期配置为10天;网段10.1.1.128/25内PC为办公室2员工办公终端,IP地址租期配置为2天。
操作步骤
1.使能DHCP服务
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dhcp enable
2.配置接口加入VLAN
# 配置GE0/0/1接口加入VLAN10。
[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
# 配置GE0/0/2加接口入VLAN11。
[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
3.配置VLANIF接口IP地址
# 配置VLANIF10接口地址。
[Switch] interface vlanif 10 [Switch-Vlanif10] ip address 10.1.1.1 25 [Switch-Vlanif10] quit
# 配置VLANIF11接口地址。
[Switch] interface vlanif 11 [Switch-Vlanif11] ip address 10.1.1.129 25 [Switch-Vlanif11] quit
4.配置全局地址池
# 配置全局地址池pool1中的IP地址池和相关网络参数。
[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
# 配置全局地址池pool2中的IP地址池和相关网络参数。
[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
5.使能DHCP服务器
# 在Vlanif10接口下使能DHCP服务器。
[Switch] interface vlanif 10 [Switch-Vlanif10] dhcp select global [Switch-Vlanif10] quit
# 在Vlanif11接口下使能DHCP服务器。
[Switch] interface vlanif 11 [Switch-Vlanif11] dhcp select global [Switch-Vlanif11] quit
6.验证配置结果
# 在Switch上执行命令display ip pool name pool1来查看全局地址池pool1的分配情况,“Used”字段显示已经分配出去的IP地址数量。以下显示信息以V200R011C10版本为例。
[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 -------------------------------------------------------------------------------
# 在Switch上执行命令display ip pool name pool2来查看全局地址池pool2的分配情况,“Used”字段显示已经分配出去的IP地址数量。以下显示信息以V200R011C10版本为例。
[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 -------------------------------------------------------------------------------