示例拓扑结构如下图,SwitchA、SwitchB、SwitchC、SwitchD都运行MSTP。它们彼此相连形成了一个环网,因为在SwitchA与SwitchB之间,以及SwitchC与SwitchD之间都存在冗余链路(本来这些链路都是可以不要的)。为实现VLAN2~VLAN10和VLAN11~VLAN20的流量负载分担,采用MSTP协议配置了两个MSTI,即MSTI1和MSTi2。
(1) 在4台交换机分别创建一个相同的MST域(域名假设为RG1)、两个多生成树实例MSTI1和MSTI2,然后创建ID为2~10r VLAN映射到MSTI1的映射,创建ID为11~20的VLAN映射到MSTI2的映射。并激活MST域配置。
SwithcA上的MST域配置
[SwitchA] stp region-configuration
[SwitchA-mst-region] region-name RG1
[SwitchA-mst-region] instance 1 vlan 2 to 10
[SwitchA-mst-region]instance 2 vlan 11 to 20
[SwitchA-mst-region] active region-configuration
[SwitchA-mst-region]quit
SwithcB上的MST域配置
[SwitchB] stp region-configuration
[SwitchB-mst-region] region-name RG1
[SwitchB-mst-region] instance 1 vlan 2 to 10
[SwitchB-mst-region]instance 2 vlan 11 to 20
[SwitchB-mst-region] active region-configuration
[SwitchB-mst-region]quit
SwitchC上的配置
[SwitchC] stp region-configuration
[SwitchC-mst-region] region-name RG1
[SwitchC-mst-region] instance 1 vlan 2 to 10
[SwitchC-mst-region]instance 2 vlan 11 to 20
[SwitchC-mst-region] active region-configuration
[SwitchC-mst-region]quit
SwitchD上的配置
stp region-configuration
region-name RG1
instance 1 vlan 2 to 10
instance 2 vlan 11 to 20
active region-configuration
(2)配置MSTI1与MSTI2的根桥和备份根桥。
[SwitchA]stp instance 1 root primary #___配置SwitchA为MSTI1的根桥
[SwitchB]stp instance 1 root secondary #___配置SwitchB为MSTI1的备份根桥
[SwitchA]stp instance 2 root secondary #___配置SwitchA为MSTI2的备份根桥
[SwitchB]stp instance 2 root primary #___配置SwitchB为MSTI2的根桥
(3)配置MSTI1和MSTI2中要被阻塞的端口,以便消除二层环路。
因为本示例中其他端口都是采用对应类型端口的缺省路径开销值,所以要阻塞某端口时只需要把它们的路径开销值配置为大于缺省即可。路径开销值越大,成为根端口的可能性越小。
[SwitchA]stp pathcost-standard legacy #___配置采用华为私有端口路径开销计算方法
[SwitchB]stp pathcost-standard legacy
[SwitchC]stp pathcost-standard legacy
[SwitchC]int g0/0/2
[SwitchC-GigabitEthernet0/0/2]stp instance 2 cost 20000 #__将端口G0/0/2在实例MSTI2中的路径开销值配置为20000
[SwitchD]stp pathcost-standard legacy
[SwitchD]int g0/0/2
[SwitchD-GigabitEthernet0/0/2]stp instance 1 cost 20000
(4)在4台交换机上全局全能MSTP,使以上MSTP配置生效,消除二层环路。
[SwitchA]stp enable
[SwitchB]stp enable
[SwitchC]stp enable
[SwitchD]stp enable
(5)将与终端PC相连的端口去全能MSTP
[SwitchC]int g0/0/1
[SwitchC-GigabitEthernet0/0/1]stp disable
[SwitchC-GigabitEthernet0/0/1]quit
[SwitchD]int g0/0/1
[SwitchD-GigabitEthernet0/0/1]stp disable
[SwitchD-GigabitEthernet0/0/1]quit
(6) 在两实例的根桥设备的指定端口上配置根保护功能
[SwitchA]int g0/0/1
[SwitchA-GigabitEthernet0/0/1]stp root-protection
[SwitchB]int g0/0/1
[SwitchB-GigabitEthernet0/0/1]stp root-protection
(7)最后在各交换机创建ID呈为2~20r aw 19个VLAN,然后把4台交换机间的直连链路的端口配置为Trunk类型,并允许这19个VLAN通过。把连接PC的链路端口设置为Access 类型,加入对应的VLAN。
SwitchA上的配置
[SwitchA]vlan batch 2 to 20
[SwitchA]int g0/0/1
[SwitchA-GigabitEthernet0/0/1]port link-type trunk
[SwitchA-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 20
[SwitchA-GigabitEthernet0/0/1]quit
[SwitchA]int g0/0/2
[SwitchA-GigabitEthernet0/0/2]port link-type trunk
[SwitchA-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 20
[SwitchA-GigabitEthernet0/0/2]quit
SwitchB上的配置
vlan batch 2 to 20
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 20
stp root-protection
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 20
SwitchC上的配置
vlan batch 2 to 20
interface GigabitEthernet0/0/1
port link-type access
port default vlan 2
stp disable
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 20
stp instance 2 cost 20000
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 20
#
SwitchD上的配置
vlan batch 2 to 20
interface GigabitEthernet0/0/1
port link-type access
port default vlan 11
stp disable
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 20
stp instance 1 cost 20000
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 20
经过以上配置,在网络计算稳定后可使用以下display命令验证配置结果。如在SwitchA 执行display stp brief命令可以查看端口状态和端口的保护类型,结果如下。从中可以看到,由于AwitchA是根桥,其G0/0/1 和G0/0/2端口成为指定端口(其中在G0/0/1端口上配置了根保护);在MSTI2中,SwitchA非根桥,其G0/0/1端口成为指定端口端口G0/0/2端口成为根端口。符合本示例中两MSTI生成树拓扑要求。
<SwitchA>display stp bri
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING ROOT
0 GigabitEthernet0/0/2 ROOT FORWARDING NONE
0 GigabitEthernet0/0/3 ALTE DISCARDING NONE
1 GigabitEthernet0/0/1 DESI FORWARDING ROOT
1 GigabitEthernet0/0/2 DESI FORWARDING NONE
2 GigabitEthernet0/0/1 DESI FORWARDING ROOT
2 GigabitEthernet0/0/2 ROOT FORWARDING NONE
在SwitchB上执行display stp brief命令,结果如下。从中可以看出,在MSTI2中,由于SwitchB是根桥,其g0/0/1和g0/0/2端口为指定端口(其中,在g0/0/1端口上配置了根保护);在MSTI1中,SwitchB 为非根桥,其g0/0/1端口成为指定端口,g0/0/2端口成为根端口,符合本示例中两MSTI生成树拓扑要求。
<SwitchB>dis stp bri
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING ROOT
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
1 GigabitEthernet0/0/1 DESI FORWARDING ROOT
1 GigabitEthernet0/0/2 ROOT FORWARDING NONE
2 GigabitEthernet0/0/1 DESI FORWARDING ROOT
2 GigabitEthernet0/0/2 DESI FORWARDING NONE
在SwitchC上执行display stp interface brief命令,结果如下。从中可以看出,SwitchC的g0/0/3端口在MSTI1和MSTI2中均为根端口,g0/0/2在MSTI2中被阻塞,在MSTI1中被计算为指定端口,也符合本示例中两MSTI生成树拓扑要求。
<SwitchC>dis stp interface g0/0/3 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/3 ALTE DISCARDING NONE
1 GigabitEthernet0/0/3 ROOT FORWARDING NONE
2 GigabitEthernet0/0/3 ROOT FORWARDING NONE
<SwitchC>dis stp interface g0/0/2 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/2 ROOT FORWARDING NONE
1 GigabitEthernet0/0/2 DESI FORWARDING NONE
2 GigabitEthernet0/0/2 ALTE DISCARDING NONE
在SwitchD上执行display stp interface brief命令,结果如下 。从中可以看出,SwitchD的g0/0/3端口在MSTI1和MSTI2中均为根端口,g0/0/2端口在MSTI1中被阻塞,在MSTI2中被计算为指定端口。
<SwitchD>dis stp interface g0/0/3 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
1 GigabitEthernet0/0/3 ROOT FORWARDING NONE
2 GigabitEthernet0/0/3 ROOT FORWARDING NONE
<SwitchD>dis stp interface g0/0/2 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
1 GigabitEthernet0/0/2 ALTE DISCARDING NONE
2 GigabitEthernet0/0/2 DESI FORWARDING NONE