拓扑图
接口说明
- VLAN10对应的网段为192.168.10.0/24;VLAN20对应的网段为192.168.20.0/24;
VLAN30对应的网段为192.168.30.0/24;VLAN40对应的网段为192.168.40.0/24;
各VLAN的网关均为.254的地址,该地址为VRRP组的虚拟地址; - LSW1的vlanif10和vlanif20的IP地址分别为:192.168.10.253、192.168.20.253
LSW1的vlanif30和vlanif40的IP地址分别为:192.168.30.252、192.168.40.252 - LSW1的vlanif10和vlanif20的IP地址分别为:192.168.10.252、192.168.20.252
LSW1的vlanif30和vlanif40的IP地址分别为:192.168.30.253、192.168.40.253 - 网络中有4个VLAN:10、20、30、40;
需求/目的
- 由于网络中VLAN较多,并且存在二层环路因此使用MSTP实现环路避免,同时实现负载分担。
- 将vlan10、20映射到MSTP实例1;将vlan30、40映射到MSTP实例2;
- MSTP实例1Block掉的端口为LSW3的GE0/0/4;实例2Block掉的端口为LSW2的GE0/0/5;
- 为了提高网络的网关层冗余能力,在SW1及SW2的vlanif10、vlanif20、vlanif30、vlanif40上部署VRRP,一共4组。而VRRP的Master及Backup需与MSTP的主、备根重叠。也就是说LSW1的vlanif10及vlanif20为各自VRRP组的Master,此外vlanif30及vlanif40为各自VRRP组的Backup;LSW2正好相反。
实验步骤
<进入系统视图>
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
<关闭状态检测,在实际生产环境中不用关闭>
[Huawei]undo in en
Info: Information center is disabled.
<重命名>
[Huawei]sysname LSW3
[LSW3]
LSW1配置
- 划分vlan并接入
[LSW1]vlan batch 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW1]int g0/0/3
[LSW1-GigabitEthernet0/0/3]p l t (port link-type trunk)
[LSW1-GigabitEthernet0/0/3]p t a v 10 20 30 40 (或者全放all)(port trunk allow-pass vlan 10 20 30 40)
<打印此接口配置信息>
[LSW1-GigabitEthernet0/0/3]d th (display this)
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20 30 40
#
return
[LSW1-GigabitEthernet0/0/3]int g0/0/4
[LSW1-GigabitEthernet0/0/4]p l t
[LSW1-GigabitEthernet0/0/4]p t a v 10 20 30 40
<打印此接口配置信息>
[LSW1-GigabitEthernet0/0/4]d th
- MSTP配置
- 配置MSTP,将vlan10 20映射到实例1,将vlan30 40映射到实例2
- 将LSW1的MSTP设置为实例1的主根,实例2的次根
[LSW1]stp mode mstp
[LSW1]stp region-configuration
[LSW1-mst-region]region-name chp
[LSW1-mst-region]instance 1 vlan 10 20
[LSW1-mst-region]instance 2 vlan 30 40
[LSW1-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
<打印此接口配置信息>
[LSW1-mst-region]d th
#
stp region-configuration
region-name chp
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration
#
return
####################
[LSW1]stp instance 1 root primary
[LSW1]stp instance 2 root secondary
[LSW1]stp enable
- 配置VRRP
- 配置vlanif10、vlanif20、vlanif30、vlanif40
- 配置vlanif10、vlanif20、vlanif30、vlanif40,分别加入VRRP组1,2,3,4
- 其中LSW1为VRRP组1及2的Master,为组3及4的Backup
<进入接口>
[LSW1]interface Vlanif 10
<配置IP>
[LSW1-Vlanif10]ip address 192.168.10.253 24
<配置VRRP虚拟IP>
[LSW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254
<配置vrrp vrid 1 的优先级,默认100 ,越大越优先>
[LSW1-Vlanif10]vrrp vrid 1 priority 120
<启用抢占模式并将延迟时间设置为20 秒,发生故障,等待20秒接管>
[LSW1-Vlanif10]vrrp vrid 1 preempt-mode timer delay 20
[LSW1-Vlanif10]d th
#
interface Vlanif10
ip address 192.168.10.253 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.10.254
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
#
return
##############
[LSW1-Vlanif10]int vlanif 20
[LSW1-Vlanif20]ip address 192.168.20.253 24
[LSW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254
[LSW1-Vlanif20]vrrp vrid 2 priority 120
[LSW1-Vlanif20]vrrp vrid 2 preempt-mode timer delay 20
##############
[LSW1-Vlanif20]int vlanif 30
[LSW1-Vlanif30]ip address 192.168.30.252 24
[LSW1-Vlanif30]vrrp vrid 3 virtual-ip 192.168.30.254
##############
[LSW1-Vlanif30]int vlanif 40
[LSW1-Vlanif40]ip address 192.168.40.252 24
[LSW1-Vlanif40]vrrp vrid 4 virtual-ip 192.168.40.254
LSW2配置(和LSW1差不多,就是调转)
- 划分VLAN
[LSW2]vlan batch 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW2]int g0/0/3
[LSW2-GigabitEthernet0/0/3]p l t
[LSW2-GigabitEthernet0/0/3]p t a v 10 20 30 40
[LSW2-GigabitEthernet0/0/3]d th
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 10 20 30 40
#
return
[LSW2-GigabitEthernet0/0/3]int g0/0/5
[LSW2-GigabitEthernet0/0/5]p l t
[LSW2-GigabitEthernet0/0/5]p t a v 10 20 30 40
- MSTP配置
- 配置MSTP,将vlan10 20映射到实例1,将vlan30 40映射到实例2
- 将LSW2的MSTP设置为实例2的主根,实例1的次根
[LSW2]stp mode mstp
[LSW2]stp region-configuration
[LSW2-mst-region]region-name chp
[LSW2-mst-region]instance 1 vlan 10 20
[LSW2-mst-region]instance 2 vlan 30 40
[LSW2-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[LSW2-mst-region]q
[LSW2]stp instance 1 root secondary
[LSW2]stp instance 2 root primary
[LSW2]stp enable
- 配置VRRP
- 配置vlanif10、vlanif20、vlanif30、vlanif40
- 配置vlanif10、vlanif20、vlanif30、vlanif40,分别加入VRRP组1,2,3,4
- 其中LSW2为VRRP组3及4的Master,为组1及2的Backup
[LSW2]int vlanif10
[LSW2-Vlanif10]ip address 192.168.10.252 24
[LSW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254
[LSW2-Vlanif10]int vlanif20
[LSW2-Vlanif20]ip address 192.168.20.252 24
[LSW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254
[LSW2-Vlanif20]int vlanif30
[LSW2-Vlanif30]ip address 192.168.30.252 24
[LSW2-Vlanif30]vrrp vrid 3 virtual-ip 192.168.30.254
[LSW2-Vlanif30]vrrp vrid 3 priority 120
[LSW2-Vlanif30]int vlanif40
[LSW2-Vlanif40]ip address 192.168.40.252 24
[LSW2-Vlanif40]vrrp vrid 4 virtual-ip 192.168.40.254
[LSW2-Vlanif40]vrrp vrid 4 priority 120
LSW3配置
- 创建vlan并接入
[LSW3]int g0/0/4
[LSW3-GigabitEthernet0/0/4]p l t
[LSW3-GigabitEthernet0/0/4]p t a v 10 20 30 40
[LSW3-GigabitEthernet0/0/4]d th
[LSW3-GigabitEthernet0/0/4]int g0/0/05
[LSW3-GigabitEthernet0/0/5]p l t
[LSW3-GigabitEthernet0/0/5]p t a v 10 20 30 40
- 配置MSTP
- 配置MSTP,将vlan10 20映射到实例1,将vlan30 40映射到实例2
- 在SW3上,MSTP实例1及实例2的优先级保持默认32768
[LSW3]stp mode mstp
[LSW3]stp region-configuration
[LSW3-mst-region]region-name chp
[LSW3-mst-region]instance 1 vlan 10 20
[LSW3-mst-region]instance 2 vlan 30 40
[LSW3-mst-region]active region-configuration
[LSW3-mst-region]q
[LSW3]stp instance 1 priority 32768
[LSW3]stp instance 2 priority 32768
[LSW3]stp enable
完成配置后,各VLAN的用户都能够ping通自己的网关;
验证
LSW1验证
LSW2验证
我们看到,MSTP实例1中被Block掉的端口是GE0/0/5口;MSTP实例2中被Block掉的端口是GE0/0/4,符合我们的需求。再去LSW2上看看VRRP组的状态: