MSTP+链路聚合实验

多生成树(MST)是把IEEE802.1w 的快速生成树(RST)算法扩展而得到的,多生成树协议定义文档是IEEE802.1S。

多生成树提出了域的概念,在域的内部可以生成多个生成树实例,并将VLAN关联到相应的实例中,每个VLAN只能关联到一个实例中。这样在域内部每个生成树实例就形成一个逻辑上的树拓扑结构,在域与域之间由CIST实例将各个域连成一个大的生成树。各个VLAN内的数据在不同的生成树实例内进行转发,这样就提供了负载均衡功能。

MSTP(Multiple Spanning Tree Protocol,多生成树协议)

将存在环路的网络修剪成为一个无环的树型网络,避免报文在环路网络中的增生和无限循环,同时还提供了数据转发的多个冗余路径,在数据转发过程中实现VLAN 数据的负载均衡。MSTP 兼容STP 和RSTP,并且可以弥补STP 和RSTP 的缺陷。它既可以快速收敛,也能使不同VLAN 的流量沿各自的路径分发,从而为冗余链路提供了更好的负载分担机制。

MSTP与其他几种生成树协议对比:
在这里插入图片描述


实验模拟
在这里插入图片描述
实验拓扑如上图所示。设PC8、9、10为vlan 10中的设备,PC11、12/13为vlan 20中的设备,使SW-1成为vlan 10的根桥交换机,SW-2成为vlan 20的交换机。要求:运行MSTP,防止环路存在,同时实现负载均衡。
注意:运行MSTP需要在每台交换机上都进行配置。

SW-1

SW-1(config)#interface range g0/0-1
SW-1(config-if-range)#switchport trunk encapsulation dot1q 
SW-1(config-if-range)#switchport mode trunk 
SW-1(config-if-range)#exit
SW-1(config)#interface range g1/0-1
SW-1(config-if-range)#switchport trunk encapsulation dot1q 
SW-1(config-if-range)#switchport mode trunk 
SW-1(config-if-range)#exit
SW-1(config)#vlan 10
SW-1(config-vlan)#vlan 20
SW-1(config-vlan)#exit
SW-1(config)#spanning-tree mode mst 
//进入MSTP的配置模式下
SW-1(config)#spanning-tree mst configuration 
//设置域名,所有运行MSTP的设备应当一致
SW-1(config-mst)#name cisco

SW-1(config-mst)#revision 1//设置版本号
//创建实例
SW-1(config-mst)#instance 1 vlan 10 
SW-1(config-mst)#instance 2 vlan 20
//查看实例信息
SW-1(config-mst)#show pending 
Pending MST configuration
Name      [cisco]
Revision  1     Instances configured 3

Instance  Vlans mapped
--------  ---------------------------------------------------------------------
0         1-9,11-19,21-4094
1         10
2         20
-------------------------------------------------------------------------------
SW-1(config-mst)#exit
//基于实例设置优先级
SW-1(config)#spanning-tree mst 1 priority 0
SW-1(config)#spanning-tree mst 2 priority 4096
//检查配置是否正确
SW-1(config)#do show running-config | section spanning-tree
spanning-tree mode mst
spanning-tree extend system-id
spanning-tree mst configuration
 name cisco
 revision 1
 instance 1 vlan 10
 instance 2 vlan 20
spanning-tree mst 1 priority 0
spanning-tree mst 2 priority 4096
//另一种设置实例优先级的方法
SW-(config)#spanning-tree mst 1 root primary 

SW-2

SW-2(config)#interface range g0/0-1
SW-2(config-if-range)#switchport trunk encapsulation dot1q 
SW-2(config-if-range)#switchport mode trunk 
SW-2(config-if-range)#exit
SW-2(config)#interface range g1/0-1
SW-2(config-if-range)#switchport trunk encapsulation dot1q 
SW-2(config-if-range)#switchport mode trunk 
SW-2(config-if-range)#exit
SW-2(config)#vlan 10
SW-2(config-vlan)#vlan 20
SW-2(config-vlan)#exit
SW-2(config)#spanning-tree mode mst 
SW-2(config)#spanning-tree mst configuration 
SW-2(config-mst)#name cisco
SW-2(config-mst)#revision 1
SW-2(config-mst)#instance 1 vlan 10
SW-2(config-mst)#instance 2 vlan 20
SW-2(config-mst)#exit
SW-2(config)#spanning-tree mst 1 priority 4096
SW-2(config)#spanning-tree mst 2 priority 0
//检查配置是否正确
SW-2(config)#do show running-config | section spanning-tree
spanning-tree mode mst
spanning-tree extend system-id
spanning-tree mst configuration
 name cisco
 revision 1
 instance 1 vlan 10
 instance 2 vlan 20
spanning-tree mst 1 priority 4096
spanning-tree mst 2 priority 0
//另一种设置实例优先级的方法
SW-2(config)#spanning-tree mst 2 root primary 

SW-3

SW-3(config)#interface range g0/1-2
SW-3(config-if-range)#switchport trunk encapsulation dot1q 
SW-3(config-if-range)#switchport mode trunk 
SW-3(config-if-range)#exit
SW-3(config)#vlan 10
SW-3(config-vlan)#exit
SW-3(config)#interface range g1/0-2
SW-3(config-if-range)#switchport mode access 
SW-3(config-if-range)#switchport access vlan 10
SW-3(config-if-range)#exit
SW-3(config)#spanning-tree mode mst 
SW-3(config)#spanning-tree mst configuration 
SW-3(config-mst)#name cisco
SW-3(config-mst)#revision 1
SW-3(config-mst)#instance 1 vlan 10
SW-3(config-mst)#exit
//查看实例信息
SW-3(config)#do show spanning-tree mst 1

##### MST1    vlans mapped:   10
Bridge        address 5000.0003.0000  priority      32769 (32768 sysid 1)
Root          this switch for MST1

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/1            Altn BLK 20000     128.2    Shr Bound(RSTP) 
Gi0/2            Mstr FWD 20000     128.3    Shr Bound(RSTP) 
Gi1/0            Desg FWD 20000     128.5    Shr 
Gi1/1            Desg FWD 20000     128.6    Shr 
Gi1/2            Desg FWD 20000     128.7    Shr 

SW-4

SW-4(config)#interface range g0/1-2
SW-4(config-if-range)#switchport trunk encapsulation dot1q 
SW-4(config-if-range)#switchport mode trunk 
SW-4(config-if-range)#exit
SW-4(config)#vlan 20
SW-4(config-vlan)#exit
SW-4(config)#interface range g1/0-2
SW-4(config-if-range)#switchport mode access 
SW-4(config-if-range)#switchport access vlan 20
SW-4(config-if-range)#exit
SW-4(config)#spanning-tree mode mst 
SW-4(config)#spanning-tree mst configuration 
SW-4(config-mst)#name cisco
SW-4(config-mst)#revision 1
SW-4(config-mst)#instance 2 vlan 20
SW-4(config-mst)#exit

通过查看端口状态,可验证无环路要求已实现。要想实现负载均衡,还需进行链路聚合的相关配置。

扫描二维码关注公众号,回复: 9591655 查看本文章

链路聚合

链路聚合是将两个或更多数据信道结合成一个单个的信道,该信道以一个单个的更高带宽的逻辑链路出现。链路聚合一般用来连接一个或多个带宽需求大的设备,例如连接骨干网络的服务器或服务器群。
端口汇聚是将多个端口汇聚在一起形成一个汇聚组,以实现出/入负荷在汇聚组中各个成员端口中的分担,同时也提供了更高的连接可靠性。

公有:LACP(Link Aggregation Control Protocol,链路汇聚控制协议)。是一种实现链路动态汇聚的协议。LACP协议通过LACPDU(Link Aggregation Control Protocol Data Unit,链路汇聚控制协议数据单元)与对端交互信息。启用某端口的LACP协议后,该端口将通过发送LACPDU向对端通告自己的系统优先级、系统MAC地址、端口优先级、端口号和操作Key。对端接收到这些信息后,将这些信息与其它端口所保存的信息比较以选择能够汇聚的端口,从而双方可以对端口加入或退出某个动态汇聚组达成一致。

操作Key是在端口汇聚时,LACP协议根据端口的配置(即速率、双工、基本配置、管理Key)生成的一个配置组合。动态汇聚端口在启用LACP协议后,其管理Key缺省为零。静态汇聚端口在启用LACP后,端口的管理Key与汇聚组ID相同。

私有:端口聚集协议(PAgP)(Port Aggregation Protocol)是Cisco的专有协议,PAgP是一种管理功能,它在链路的任一末端检查参数的一致性,并且有助于保持网络可用性。 PAgP 分组为了商议一个通道的形成在快速以太通道可能的端口发送。
在这里插入图片描述
主动模式:主动发送协商包,主动发起协商
被动模式:接收协商包,进行协商

LACP;聚合链路可以为2、4、8、16条。最大可以聚合链路为8条,剩余8条作为备份存在。
PAgP:2、4、8条。
SW-1

SW-1(config)#interface range g1/0-1
//描述协议信息,与具体使用什么协议无关
SW-1(config-if-range)#channel-protocol lacp

//设置聚合组编号
SW-1(config-if-range)#channel-group 1 mode passive 


//查看配置信息
SW-1(config)#do sh etherchannel summary 
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      N - not in use, no aggregation
        f - failed to allocate aggregator

        M - not in use, minimum links not met
        m - not in use, port not aggregated due to minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port

        A - formed by Auto LAG


Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SD)         LACP      Gi1/0(s)    Gi1/1(s)    

SW-2

SW-2(config)#interface range g1/0-1
SW-2(config-if-range)#channel-protocol lacp
SW-2(config-if-range)#channel-group 1 mode active 
/*提示信息:Creating a port-channel interface Port-channel 1*/

//查看配置信息
SW-2(config)#do show etherchannel summary 
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      N - not in use, no aggregation
        f - failed to allocate aggregator

        M - not in use, minimum links not met
        m - not in use, port not aggregated due to minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port

        A - formed by Auto LAG


Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)         LACP      Gi1/0(P)    Gi1/1(P)    

在这里插入图片描述
通过查看带宽信息,我们可以发现SW-2的带宽从之前的1G变为现在的2G,实现了链路聚合。

链路聚合默认情况下基于源目IP负载(可修改)

//可修改为下列几种负载方式
SW-2(config)#port-channel load-balance ?
  dst-ip       Dst IP Addr
  dst-mac      Dst Mac Addr
  src-dst-ip   Src XOR Dst IP Addr
  src-dst-mac  Src XOR Dst Mac Addr
  src-ip       Src IP Addr
  src-mac      Src Mac Addr

其他查看配置命令:

SW-2(config)#do show run | section channel
interface Port-channel1
 switchport trunk encapsulation dot1q
 switchport mode trunk
 channel-protocol lacp
 channel-group 1 mode active
 channel-protocol lacp
 channel-group 1 mode active


SW-2(config)#do show run | section channel-group
 channel-group 1 mode active
 channel-group 1 mode active


SW-2(config)#do show etherchannel load-balance 
EtherChannel Load-Balancing Configuration:
        src-dst-ip

EtherChannel Load-Balancing Addresses Used Per-Protocol:
Non-IP: Source XOR Destination MAC address
  IPv4: Source XOR Destination IP address
  IPv6: Source XOR Destination IP address

当存在两条聚合链路时,可通过设置优先级的情况下改变链路使用状态
查看默认情况下的聚合链路信息

SW-2(config)#do show etherchannel port 
		Channel-group listing: 
		----------------------

Group: 1 
----------
		Ports in the group:
		-------------------
Port: Gi1/0
------------

Port state    = Up Mstr Assoc In-Bndl 
Channel group = 1           Mode = Active          Gcchange = -
Port-channel  = Po1         GC   =   -             Pseudo port-channel = Po1
Port index    = 0           Load = 0x00            Protocol =   LACP

Flags:  S - Device is sending Slow LACPDUs   F - Device is sending fast LACPDUs.
        A - Device is in active mode.        P - Device is in passive mode.

Local information:
                            LACP port     Admin     Oper    Port        Port
Port      Flags   State     Priority      Key       Key     Number      State
Gi1/0     SA      bndl      32768         0x1       0x1     0x101       0x3D  

Partner's information:
          
                  LACP port                        Admin  Oper   Port    Port
Port      Flags   Priority  Dev ID          Age    key    Key    Number  State
Gi1/0     SP      32768     5000.0001.0000   8s    0x0    0x1    0x101   0x3C  
          
Age of the port in the current state: 0d:00h:15m:49s
          
Port: Gi1/1
------------
          
Port state    = Up Mstr Assoc In-Bndl 
Channel group = 1           Mode = Active          Gcchange = -
Port-channel  = Po1         GC   =   -             Pseudo port-channel = Po1
Port index    = 0           Load = 0x00            Protocol =   LACP
          
Flags:  S - Device is sending Slow LACPDUs   F - Device is sending fast LACPDUs.
        A - Device is in active mode.        P - Device is in passive mode.
          
Local information:
                            LACP port     Admin     Oper    Port        Port
Port      Flags   State     Priority      Key       Key     Number      State
Gi1/1     SA      bndl      32768         0x1       0x1     0x102       0x3D  
          
Partner's information:
          
                  LACP port                        Admin  Oper   Port    Port
Port      Flags   Priority  Dev ID          Age    key    Key    Number  State
Gi1/1     SP      32768     5000.0001.0000  11s    0x0    0x1    0x102   0x3C  
          
Age of the port in the current state: 0d:00h:15m:47s

观察相关的信息我们可以发现,默认优先级为32768.
修改方法:

SW-2(config)#interface g1/0
SW-2(config-if)#lacp por
SW-2(config-if)#lacp port-priority ?
  <0-65535>  Priority value

需要注意的是,若修改聚合链路优先级,应当将本端口和对端端口的优先级进行同步配置,不可只配置一个端口。

发布了29 篇原创文章 · 获赞 24 · 访问量 7821

猜你喜欢

转载自blog.csdn.net/zhang175gl/article/details/104570657