此拓扑出自2021年网络工程师软考下午试题(三),相关配置参考华为官方文档。

DHCP策略VLAN(简单)

Haiwei-DHCP策略VLAN实验案例配置_Ethernet

地址规划表

接口

地址

Vlanif10

10.10.10.1/24

Vlanif20

10.10.20.1/24

Vlanif30

10.10.30.1/24

项目实施

一、配置VLAN和DHCP

1、SwitchA的配置

[SwitchA]vlan batch 10 20 30 
Info: This operation may take a few seconds. Please wait for a moment...done.
[SwitchA]dhcp enable
[SwitchA]int Vlanif 10
[SwitchA-Vlanif10]ip address 10.10.10.1 255.255.255.0
[SwitchA-Vlanif10]dhcp select interface
[SwitchA]int Vlanif 20
[SwitchA-Vlanif20]ip address 10.10.20.1 255.255.255.0
[SwitchA-Vlanif20]dhcp select interface
[SwitchA]int Vlanif 30
[SwitchA-Vlanif30]ip address 10.10.30.1 255.255.255.0
[SwitchA-Vlanif30]dhcp select interface

2、SwitchB的配置

[SwitchB]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SwitchB]dhcp enable

3、SwitchC的配置

[SwitchC]vlan batch 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SwitchC]dhcp enable

二、配置接口

1、SwitchA的配置

[SwitchA]interface GigabitEthernet 0/0/1
[SwitchA-GigabitEthernet0/0/1]port link-type trunk
[SwitchA-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20

[SwitchA]interface GigabitEthernet 0/0/2
[SwitchA-GigabitEthernet0/0/2]port link-type trunk
[SwitchA-GigabitEthernet0/0/2]port trunk allow-pass vlan 30

2、SwitchB的配置

[SwitchB]interface GigabitEthernet 0/0/1
[SwitchB-GigabitEthernet0/0/1]port link-type trunk
[SwitchB-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20

3、SwitchC的配置

[SwitchC]interface GigabitEthernet 0/0/1
[SwitchC-GigabitEthernet0/0/1]port link-type trunk
[SwitchC-GigabitEthernet0/0/1]port trunk allow-pass vlan 30

三、配置DHCP策略VLAN

1、SwitchB的配置

[SwitchB]vlan 10
[SwitchB]ip-subnet-vlan 1 ip 10.10.10.1 255.255.255.0 #设置IP地址为10.10.10.1/24的报文,在vlan10域内转发
[SwitchB]dhcp policy-vlan mac-address 0081-01fa-2134 #配置基于MAC地址DHCP策略VLAN,
使得拥有此MAC的新主机通过DHCP服务器获取到合法地址
[SwitchB]vlan 20
[SwitchB-vlan20]ip-subnet-vlan 1 ip 10.10.20.1 255.255.255.0
[SwitchB-vlan20]dhcp policy-vlan port Ethernet 0/0/3 #配置基于端口DHCP策略VLAN,
使得接入此接口的新主机通过DHCP服务器获取到合法地址
[SwitchB]int Ethernet 0/0/2
[SwitchB-Ethernet0/0/2]port hybrid untagged vlan 10
[SwitchB-Ethernet0/0/2]ip-subnet-vlan enable #开启基于子网划分VLAN功能

[SwitchB]int Ethernet 0/0/3
[SwitchB-Ethernet0/0/2]port hybrid untagged vlan 20
[SwitchB-Ethernet0/0/2]ip-subnet-vlan enable #开启基于子网划分VLAN功能

2、SwitchC的配置

[SwitchC]vlan 30
[SwitchC-vlan30]ip-subnet-vlan 1 ip 10.10.30.1 255.255.255.0
[SwitchC-vlan30]dhcp policy-vlan generic #配置普通的DHCP策略VLAN,优先级是三种策略中最低的
#实现使新加入网络的主机能够通过DHCP服务器获得合法的IP地址

[SwitchC]int Ethernet 0/0/2
[SwitchC-Ethernet0/0/2]port hybrid untagged vlan 30
[SwitchC-Ethernet0/0/2]ip-subnet-vlan enable #开启基于子网划分VLAN功能

[SwitchC]int Ethernet 0/0/3
[SwitchC-Ethernet0/0/2]port hybrid untagged vlan 30
[SwitchC-Ethernet0/0/2]ip-subnet-vlan enable #开启基于子网划分VLAN功能

配置结果

一、DHCP合法地址获取结果

Haiwei-DHCP策略VLAN实验案例配置_网络技术_02

Haiwei-DHCP策略VLAN实验案例配置_DHCP_03

Haiwei-DHCP策略VLAN实验案例配置_子网划分_04

[SwitchA]display ip pool  
-----------------------------------------------------------------------
Pool-name : vlanif30
Pool-No : 0
Position : Interface Status : Unlocked
Gateway-0 : 10.10.30.1
Mask : 255.255.255.0
VPN instance : --

-----------------------------------------------------------------------
Pool-name : vlanif10
Pool-No : 1
Position : Interface Status : Unlocked
Gateway-0 : 10.10.10.1
Mask : 255.255.255.0
VPN instance : --

-----------------------------------------------------------------------
Pool-name : vlanif20
Pool-No : 2
Position : Interface Status : Unlocked
Gateway-0 : 10.10.20.1
Mask : 255.255.255.0
VPN instance : --


IP address Statistic
Total :759
Used :4 Idle :755
Expired :0 Conflict :0 Disable :0

二、查看子网划分效果

[SwitchB]display ip-subnet-vlan vlan all
----------------------------------------------------------------
Vlan Index IpAddress SubnetMask Priority
----------------------------------------------------------------
10 1 10.10.10.1 255.255.255.0 0
20 1 10.10.20.1 255.255.255.0 0
----------------------------------------------------------------
ip-subnet-vlan count: 2 total count: 2
[SwitchC]dis ip-subnet-vlan vlan all 
----------------------------------------------------------------
Vlan Index IpAddress SubnetMask Priority
----------------------------------------------------------------
30 1 10.10.30.1 255.255.255.0 0
----------------------------------------------------------------
ip-subnet-vlan count: 1 total count: 1

此拓扑出自2021年网络工程师软考下午试题(三),相关配置参考华为官方文档。