0


mstp详解和配置

mstp详解和配置

rstp解决了stp的各种问题,比如初始化慢,直连故障要等30s,非直连要等50s,拓扑变化处理机制复杂等等

rstp详解可以看这篇博客:rstp快速生成树详解

mstp是为了解决他们共有的问题:所有的vlan在一棵生成树中,会导致链路资源的浪费,因为被阻塞的链路一直都是空闲状态,流量多时还可能造成拥塞,无法实现vlan的负载均衡
还会导致二层次优路径,部分vlan不通等情况
在这里插入图片描述mstp是一种无环,多棵生成树,既可以解决广播风暴,又可以实现vlan间负载均衡,不同vlan的流量不同路径转发

原理

和rstp选举过程是一样的,端口状态和端口角色也是,不同的是mstp的架构,mstp可以包含多个域,一个域可以包含多个实例

:是由交换机和他们之间的网段构成
实例:是将vlan包含在其中(一个实例可以包含多个vlan),形成映射关系,
个人理解可以将一个实例当作一棵生成树来看

在这里插入图片描述注:同一个域里的域名要一样,域的级别也要相同

   Format selector    :0             
   Region name        :lala              #域名      
   Revision level     :1                #级别

实验环境

在这里插入图片描述初始配置:

sw3:
vlan ba 1020int g0/0/1
port l tr 
port tr all vlan 1020int g0/0/2
port l tr 
port tr all vlan 1020int g0/0/3
port l ac
port de vlan 10int g0/0/4
port l ac
port de vlan 20----------------------------------------------------------------------
sw4:
vlan ba 1020int g0/0/1
port l tr 
port tr all vlan 1020int g0/0/2
port l tr 
port tr all vlan 1020int g0/0/3
port l ac
port de vlan 10int g0/0/4
port l ac
port de vlan 20----------------------------------------------------------------------
sw1:
vlan ba 1020100int g0/0/1
port l tr 
port tr all vlan 1020int g0/0/2
port l tr 
port tr all vlan 1020int g0/0/4
port l ac
port de vlan 100int vlan 100
ip add 1.1.1.124int vlan 10
ip add 10.0.0.25324int vlan 20 
ip add 20.0.0.25324int g0/0/3
port l tr
port tr all vlan 1020----------------------------------------------------------------------
sw2:
vlan ba 1020100int g0/0/1
port l tr 
port tr all vlan 1020int g0/0/2
port l tr 
port tr all vlan 1020int g0/0/4
port l ac
port de vlan 100int vlan 100
ip add 2.2.2.124int vlan 10
ip add 10.0.0.25224int vlan 20 
ip add 20.0.0.25224int g0/0/3
port l tr
port tr all vlan 1020

配置mstp:

 stp region-configuration        
 region-name lala
 revision-level 1
 instance 10 vlan 10        #创建实例10,并且和vlan10绑定
 instance 20 vlan 20        #创建实例20,并且和vlan20绑定

创建完成后,需要提交才可生效,但是在提交前需要先检查一下是否配置有误,因为提交就会立刻生效运行,如果错误再修改会导致网络震荡

[sw2-mst-region]check region-configuration
 Admin configuration
   Format selector    :0             
   Region name        :lala         
   Revision level     :1

   Instance   VLANs Mapped
      01 to 9,11 to 19,21 to 409410102020

确认无误后提交:

active region-configuration

这段指令需要在每台交换机上都执行一遍,否则其他交换机怎么知道实例是谁呢

查看结果:

<sw2>dis stp bri
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
   0    GigabitEthernet0/0/3        ROOT  FORWARDING      NONE
   0    GigabitEthernet0/0/4        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
  10    GigabitEthernet0/0/3        ROOT  FORWARDING      NONE
  20    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
  20    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
  20    GigabitEthernet0/0/3        ROOT  FORWARDING      NONE

[sw1-mst-region]dis stp bri
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/4        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
  10    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
  20    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
  20    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
  20    GigabitEthernet0/0/3        DESI  FORWARDING      NONE

发现MSTID有0,0是默认的实例,在没有创建别的实例前,所有vlan都属于实例0,就像端口没有绑定其他vlan时,默认都属于vlan1

这里发现不管实例10还是20,根桥都是在sw1上,sw2的0/0/2端口被阻塞,如果pc4(pc4属于实例20)想要访问路由器,明明直接从sw2上走最近,结果还要从sw1上绕,这样会导致时延较大,所以需要针对不同实例来配置根桥
sw1是实例10的根桥,sw2是实例20的根桥
在这里插入图片描述配置:

[sw1]stp instance 10 root primary 
[sw1]stp instance 20 root secondary 
----------------------------------------------------------------------[sw2]stp instance 10 root secondary 
[sw2]stp instance 20 root primary 

交换机1,2的根桥正好是相反的,因为希望vlan10都从sw1上走,vlan20从sw2上走,做到负载均衡,如果某个链路断了,可以及时切换,不会影响用户数据

验证:
可以看到sw1实例10全是指定端口,20则有root端口,说明对于20,sw1不是根桥,反之sw2同理

[sw1]dis stp vlan 10
 ProcessId   InstanceId   Port                        Role  State             
 ----------------------------------------------------------------------010        GigabitEthernet0/0/1        DESI  FORWARDING
    010        GigabitEthernet0/0/2        DESI  FORWARDING
    010        GigabitEthernet0/0/3        DESI  FORWARDING
[sw2]dis stp vlan 10
 ProcessId   InstanceId   Port                        Role  State             
 ----------------------------------------------------------------------010        GigabitEthernet0/0/1        DESI  FORWARDING
    010        GigabitEthernet0/0/2        DESI  FORWARDING
    010        GigabitEthernet0/0/3        ROOT  FORWARDING
[sw1]dis stp vlan 20
 ProcessId   InstanceId   Port                        Role  State             
 ----------------------------------------------------------------------020        GigabitEthernet0/0/1        DESI  FORWARDING
    020        GigabitEthernet0/0/2        DESI  FORWARDING
    020        GigabitEthernet0/0/3        ROOT  FORWARDING
[sw2]dis stp vlan 20
 ProcessId   InstanceId   Port                        Role  State             
 ----------------------------------------------------------------------020        GigabitEthernet0/0/1        DESI  FORWARDING
    020        GigabitEthernet0/0/2        DESI  FORWARDING
    020        GigabitEthernet0/0/3        DESI  FORWARDING

mstp和vrrp联动:

mstp还可以和vrrp联动,前提是根桥需要和master在一起,如果不在一起,到达网关后还要再多此一举的从0/0/3接口发送到对端
在这里插入图片描述

具体关于vrrp的详解可以看另一篇博客:vrrp基本原理

配置:

sw2
interface Vlanif10
 ip address 10.0.0.252255.255.255.0
 vrrp vrid 10 virtual-ip 10.0.0.254#interfaceVlanif20
 ip address 20.0.0.252255.255.255.0
 vrrp vrid 20 virtual-ip 20.0.0.254
 vrrp vrid 20 priority 110

sw1
interface Vlanif10
 ip address 10.0.0.253255.255.255.0
 vrrp vrid 10 virtual-ip 10.0.0.254
 vrrp vrid 10 priority 110#interfaceVlanif20
 ip address 20.0.0.253255.255.255.0
 vrrp vrid 20 virtual-ip 20.0.0.254

验证:

[sw1-ospf-1-area-0.0.0.0]dis vrrp brief 
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
10    Master       Vlanif10                 Normal   10.0.0.254     
20    Backup       Vlanif20                 Normal   20.0.0.254     
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0    
[sw2]dis vrrp bri
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
10    Backup       Vlanif10                 Normal   10.0.0.254     
20    Master       Vlanif20                 Normal   20.0.0.254     
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0 

通过路由追踪和抓包可以发现,vlan10的流量都是从sw1上走,vlan20从sw2上走,实现了vlan的负载均衡
在这里插入图片描述在这里插入图片描述


本文转载自: https://blog.csdn.net/qq_45309500/article/details/127550030
版权归原作者 番茄上的Tomato 所有, 如有侵权,请联系我们删除。

“mstp详解和配置”的评论:

还没有评论