MSTP:多生成树协议(华为交换机默认允许MSTP)
工作原理:将多个VLAN捆绑在一起,运行在一个STP实例里面,不同实例间的STP互相独立
注:默认情况下所有VLAN都在实例0里面
SW1——创建VLAN
1 2 3 4 | <Huawei>system-view //进入全局配置模式 [Huawei]undo info-center enable //关闭告警提示 [Huawei]sysname SW1 //改名 [SW1]vlan batch 10 20 //创建VLAN10和VLAN20 |
SW2——创建VLAN
1 2 3 4 | <Huawei>system-view //进入全局配置模式 [Huawei]undo info-center enable //关闭告警提示 [Huawei]sysname SW2 //改名 [SW2]vlan batch 10 20 //创建VLAN10和VLAN20 |
SW3——创建VLAN
1 2 3 4 | <Huawei>system-view //进入全局配置模式 [Huawei]undo info-center enable //关闭告警提示 [Huawei]sysname SW3 //改名 [SW3]vlan batch 10 20 //创建VLAN10和VLAN20 |
SW1——连接PC设置链路为access
1 2 3 4 5 | [SW1]interface g0/0/3 //进入接口 [SW1-GigabitEthernet0/0/3]port link-type access //将接口设为access链路 [SW1-GigabitEthernet0/0/3]port default vlan 10 //允许VLAN10通过 [SW1-GigabitEthernet0/0/3]quit //退出 [SW1] |
SW2——连接PC设置链路为access
1 2 3 4 5 | [SW2]interface g0/0/3 //进入接口 [SW2-GigabitEthernet0/0/3]port link-type access //将接口设为access链路 [SW2-GigabitEthernet0/0/3]port default vlan 20 //允许VLAN20通过 [SW2-GigabitEthernet0/0/3]quit //退出 [SW2] |
SW3——连接PC设置链路为access
1 2 3 4 5 6 7 8 9 | [SW3]interface g0/0/3 //进入接口 [SW3-GigabitEthernet0/0/3]port link-type access //将接口设为access链路 [SW3-GigabitEthernet0/0/3]port default vlan 10 //允许VLAN10通过 [SW3-GigabitEthernet0/0/3]quit //退出 [SW3]interface g0/0/4 //进入接口 [SW3-GigabitEthernet0/0/4]port link-type access //将接口设为access链路 [SW3-GigabitEthernet0/0/4]port default vlan 20 //允许VLAN20通过 [SW3-GigabitEthernet0/0/4]quit //退出 [SW3] |
SW1——连接交换机设置链路为trunk
1 2 3 4 5 6 7 8 9 | [SW1]port-group group-member g0/0/1 to g0/0/2 //将两个端口加入端口组 [SW1-port-group]port link-type trunk //将端口组里面的端口设置为trunk链路 [SW1-GigabitEthernet0/0/1]port link-type trunk [SW1-GigabitEthernet0/0/2]port link-type trunk [SW1-port-group]port trunk allow-pass vlan all //允许所有VLAN通过 [SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SW1-port-group]quit //退出 [SW1] |
SW2——连接交换机设置链路为trunk
1 2 3 4 5 6 7 8 9 | [SW2]port-group group-member g0/0/1 to g0/0/2 //将两个端口加入端口组 [SW2-port-group]port link-type trunk //将端口组里面的端口设置为trunk链路 [SW2-GigabitEthernet0/0/1]port link-type trunk [SW2-GigabitEthernet0/0/2]port link-type trunk [SW2-port-group]port trunk allow-pass vlan all //允许所有VLAN通过 [SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SW2-port-group]quit //退出 [SW2] |
SW3——连接交换机设置链路为trunk
1 2 3 4 5 6 7 8 9 | [SW3]port-group group-member g0/0/1 to g0/0/2 //将两个端口加入端口组 [SW3-port-group]port link-type trunk //将端口组里面的端口设置为trunk链路 [SW3-GigabitEthernet0/0/1]port link-type trunk [SW3-GigabitEthernet0/0/2]port link-type trunk [SW3-port-group]port trunk allow-pass vlan all //允许所有VLAN通过 [SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SW3-port-group]quit //退出 [SW3] |
SW2——查看交换机那个端阻塞
1 2 3 4 5 | [SW2]dis stp brief //查看STP信息 MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ALTE DISCARDING NONE //端口为阻塞端口 0 GigabitEthernet0/0/2 ROOT FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE |
SW1——SMTP配置
1 2 3 4 5 6 7 | [SW1]stp region-configuration //激活SMTP域配置 [SW1-mst-region]region-name huawei //设置SMTP域名字 [SW1-mst-region]instance 1 vlan 10 //将VLAN10划分到实例1里面 [SW1-mst-region]instance 2 vlan 20 //将VLAN20划分到实例2里面 [SW1-mst-region]active region-configuration //激活MST域的配置 [SW1-mst-region]quit //退出 [SW1] |
SW2——SMTP配置
1 2 3 4 5 6 7 | [SW2]stp region-configuration //激活SMTP域配置 [SW2-mst-region] region-name huawei //设置SMTP域名字 [SW2-mst-region] instance 1 vlan 10 //将VLAN10划分到实例1里面 [SW2-mst-region] instance 2 vlan 20 //将VLAN20划分到实例2里面 [SW2-mst-region] active region-configuration //激活MST域的配置 [SW2-mst-region]quit //退出 [SW2] |
SW3——SMTP配置
1 2 3 4 5 6 7 | [SW3]stp region-configuration //激活SMTP域配置 [SW3-mst-region] region-name huawei //设置SMTP域名字 [SW3-mst-region] instance 1 vlan 10 //将VLAN10划分到实例1里面 [SW3-mst-region] instance 2 vlan 20 //将VLAN20划分到实例2里面 [SW3-mst-region] active region-configuration //激活MST域的配置 [SW3-mst-region]quit //退出 [SW3] |
SW2—查看实例1中阻塞端口
1 2 3 4 5 | [SW2]dis stp instance 1 brief //查看实例1中端口状态 MSTID Port Role STP State Protection 1 GigabitEthernet0/0/1 ROOT FORWARDING NONE 1 GigabitEthernet0/0/2 DESI DISCARDING NONE //阻塞端口 [SW2] |
针对实例1数据包通信过程
SW2——实例2中,将次交换机的优先级调为最低,成为根桥
1 | [SW2]stp instance 2 priority 4096 //实例2中将交换机的优先级调为最低,成为根桥 |
SW2——查看实例2中的交换机优先级
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | [SW2]dis stp instance 2 //查看实例2中交换机优先级 -------[MSTI 2 Global Info]------- MSTI Bridge ID :4096.4c1f-ccc5-27fc //实例2中,此交换机的优先级最低 MSTI RegRoot/IRPC :4096.4c1f-ccc5-27fc / 0 MSTI RootPortId :0.0 Master Bridge :32768.4c1f-cc25-682f Cost to Master :20000 TC received :9 TC count per hello :0 Time since last TC :0 days 0h:2m:35s Number of TC :8 Last TC occurred :GigabitEthernet0/0/1 ----[Port1(GigabitEthernet0/0/1)][FORWARDING]---- Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :4096.4c1f-ccc5-27fc / 128.1 Port Times :RemHops 20 TC or TCN send :4 TC or TCN received :5 ----[Port2(GigabitEthernet0/0/2)][FORWARDING]---- Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :4096.4c1f-ccc5-27fc / 128.2 Port Times :RemHops 20 TC or TCN send :5 TC or TCN received :4 ----[Port3(GigabitEthernet0/0/3)][FORWARDING]---- Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :4096.4c1f-ccc5-27fc / 128.3 Port Times :RemHops 20 TC or TCN send :7 TC or TCN received :0 [SW2] |
SW2—实例2中,将SW2配置为根桥,将SW1配置为备份根桥
1 2 | [SW2]stp instance 2 root primary //SW2交换机会自动降低优先级成为实例2的根桥 [SW1]stp instance 2 root secondary //SW1交换机会自动成为备份根桥 |
SW1——查看实例2中,阻塞的端口
1 2 3 4 5 | [SW1]dis stp instance 2 brief //查看实例2中,端口状态 MSTID Port Role STP State Protection 2 GigabitEthernet0/0/1 ROOT FORWARDING NONE 2 GigabitEthernet0/0/2 DESI DISCARDING NONE //实例2中,该端口被阻塞 [SW1] |