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