同网段内配置基于接口地址池的DHCP 服务器示例组网需求如图 1 所示,某企业有两个处于同一网络内的办公室,为了节省资源,两个办公室内的主机由SwitchA 作为 DHCP 服务器统一分配IP 地址办公室 1 所属的网段为10.1.1.0/24,主机都加入VLAN10 ,办公室 1 使用 DNS服务和 NetBIOS服务,地址租期30 天;办公室2 所属的网段为,主机都加入VLAN11 ,办公室 2 不使用 DNS服务和 NetBIOS 服务,地址租期20 天配置思路基于 VLANIF 接口地址池的DHCP服务器的配置思路如下:1. 在 SwitchA 上创建两个接口地址池并配置地址池相关属性,实现DHCP 服务器可以根据不同需求,从不同的接口地址池中选择合适的IP 地址及其配置参数分配给办公室主机2. 在 SwitchA 上配置 VLANIF接口基于接口地址池的地址分配方式,实现DHCP服务器从基于接口的地址池中选择IP 地址分配给办公室主机操作步骤1. 使能 DHCP 服务2. system-view3. HUAWEI sysname SwitchASwitchA dhcp enable4. 配置接口加入VLAN# 配置 GE0/0/1 接口加入VLAN10 。
SwitchA vlan batch 10 to 11SwitchA interface gigabitethernet 0/0/1SwitchA-GigabitEthernet0/0/1 port hybrid pvid vlan 10SwitchA-GigabitEthernet0/0/1 port hybrid untagged vlan 10SwitchA-GigabitEthernet0/0/1 quit# 配置 GE0/0/2 加接口入VLAN11 SwitchA interface gigabitethernet 0/0/2SwitchA-GigabitEthernet0/0/2 port hybrid pvid vlan 11SwitchA-GigabitEthernet0/0/2 port hybrid untagged vlan 11SwitchA-GigabitEthernet0/0/2 quit5. 配置 VLANIF接口 IP 地址# 配置 VLANIF10 接口地址SwitchA interface vlanif 10SwitchA-Vlanif10 ip address 10.1.1.1 24SwitchA-Vlanif10 quit# 配置 VLANIF11 接口地址。
SwitchA interface vlanif 11SwitchA-Vlanif11 ip address 10.1.2.1 24SwitchA-Vlanif11 quit6. 使能 VLANIF接口地址池# 配置 VLANIF10 接口下的客户端从接口地址池中获取IP 地址SwitchA interface vlanif 10SwitchA-Vlanif10 dhcp select interfaceSwitchA-Vlanif10 quit# 配置 VLANIF11 接口下的客户端从接口地址池中获取IP 地址SwitchA interface vlanif 11SwitchA-Vlanif11 dhcp select interfaceSwitchA-Vlanif11 quit7. 配置接口地址池的DNS服务和 NetBIOS 服务# 配置 VLANIF10 接口地址池下的DNS服务和 NetBIOS 服务SwitchA interface vlanif 10SwitchA-Vlanif10 dhcp server domain-name SwitchA-Vlanif10 dhcp server dns-list 10.1.1.2SwitchA-Vlanif10 dhcp server nbns-list 10.1.1.3SwitchA-Vlanif10 dhcp server excluded-ip-address 10.1.1.2SwitchA-Vlanif10 dhcp server excluded-ip-address 10.1.1.3SwitchA-Vlanif10 dhcp server netbios-type b-nodeSwitchA-Vlanif10 quit8. 配置接口地址池中地址租用期限# 配置 VLANIF10 接口地址租用期限为30 天。
SwitchA interface vlanif 10SwitchA-Vlanif10 dhcp server lease day 30SwitchA-Vlanif10 quit# 配置 VLANIF11 接口地址租用期限为20 天SwitchA interface vlanif 11SwitchA-Vlanif11 dhcp server lease day 20SwitchA-Vlanif11 quit9. 验证配置结果在 SwitchA 上使用 display ip pool命令用来查看接口地址池配置情况SwitchA display ip pool interface vlanif10 Pool-name : Vlanif10 Pool-No : 0 Lease : 30 Days 0 Hours 0 Minutes Domain-name : DNS-server0 : 10.1.1.2 NBNS-server0 : 10.1.1.3 Netbios-type : b-node Position : Interface Status : Unlocked Gateway-0 : 10.1.1.1 Mask : VPN instance : - Start End Total Used Idle(Expired) Conflict Disable- 10.1.1.1 253 1 250(0) 0 2-SwitchA display ip pool interface vlanif11 Pool-name : Vlanif11 Pool-No : 1 Lease : 20 Days 0 Hours 0 Minutes Domain-name : - DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Interface Status : Unlocked Gateway-0 : 10.1.2.1 Mask : VPN instance : - Start End Total Used Idle(Expired) Conflict Disable- 10.1.2.1 253 3 250(0) 0 0- 配置文件SwitchA 的配置文件# sysname HUAWEI# vlan batch 10 to 11#dhcp enable#interface Vlanif10 ip address 10.1.1.1 dhcp select interface dhcp server excluded-ip-address 10.1.1.2 dhcp server lease day 30 hour 0 minute 0 dhcp server dns-list 10.1.1.2 dhcp server netbios-type b-node dhcp server nbns-list 10.1.1.3 dhcp server domain-name #interface Vlanif11 ip address 10.1.2.1 dhcp select interface dhcp server lease day 20 hour 0 minute 0#interface GigabitEthernet0/0/1 port hybrid pvid vlan 10 port hybrid untagged vlan 10#interface GigabitEthernet0/0/2 port hybrid pvid vlan 11 port hybrid untagged vlan 11 #return。