资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,网络互联与实现,STP,协议,Page,3,/53,本节目标,能够通过配置交换机的网桥优先级,来选择合适的根网桥,使网络的整体稳定性提高,能够通过,PVST,的配置实现交换网络的负载分担,理解,STP,的工作原理,了解,PVST,与,CST,的区别,掌握,PVST,的配置命令,能够正确的配置上行速链路和速端口,能够配置,EthernetChannel,Page,4,/53,本节结构,STP,协议,STP,的,功能,EthernetChannel,STP,的工作原理,PVST,防止广播风暴,算法,BPDU,包,生成树端口的状态,工作原理,配置,Page,5,/53,交换机工作原理,根据,MAC,地址表转发数据帧,如果地址未知,则广播,A,B,aa,bb,A,查,MAC,地址表,目的地址在表中不存在,A,广播这个数据帧,C,Page,6,/53,广播风暴的产生,当网络中存在物理环路,会产生广播风暴,A,aa,bb,B,C,A,查,MAC,地址表,目标地址在表中不存在,,A,广播这个帧,B,与,C,查,MAC,地址表,未知目标地址,,B,与,C,广播该帧,形成双向广播环,广播永远不会停止,产生广播风暴,广播风暴最终会导致网络资源耗尽,交换机死机!,Page,7,/53,STP,协议介绍,STP,Spanning Tree Protocol,(生成树协议),逻辑上断开环路,防止广播风暴的产生,当线路出现故障,断开的接口被激活,恢复通信,起备份线路的作用,A,B,C,Page,8,/53,STP,的算法,STP,将一个环形网络生成无环拓朴的步骤:,选择根网桥(,Root Bridge,),选择根端口(,Root Ports,),选择指定端口(,Designated Ports,),网桥是交换机的前身,由于,STP,是在网桥基础上开发的,因此现在在交换机的网络中仍然沿用网桥这一术语,第一步:选择根网桥,Page,9,/53,选择根网桥的依据,网桥,ID,(,BID,),网桥,ID,是唯一的,交换机之间选择,BID,值最小的交换机作为网络中的根网桥,网桥优先级,网桥的,MAC,地址,2,字节,6,字节,取值范围:,0,65535,缺省值:,32768,选择根网桥的目的是为了给将生成的树形结构确定一个树根,Page,10,/53,STP,选择根网桥举例,根据网桥,ID,选择根网桥,A,B,C,优先级:,4096MAC,地址:,000d.2800.b100,优先级:,32768MAC,地址:,000d.2800.b101,优先级:,32768MAC,地址:,000d.2800.b102,Root Bridge,下一步:选择根端口,以本拓朴为例,介绍,STP,的计算过程,Page,11,/53,选择根端口的依据,在非根网桥上选择一个到根网桥最近的端口作为根端口,选择根端口的依据是:,根路径成本最低,直连的网桥,ID,最小,端口,ID,最小,Page,12,/53,根路径成本,根路径成本是网桥到根网桥的路径上所有链路的成本之和,Root Bridge,路径成本:,19,路径成本:,100,C,B,A,Port 1,C,的,Port 1,根路径成本,19,100,119,Page,13,/53,路径成本,路径成本根据链路带宽的高低规定,链路带宽(,Mb/s,),路径成本,10,100,16,62,45,39,100,19,155,14,622,6,1000,4,10000,2,Page,14,/53,端口,ID,端口,ID,的组成,端口优先级,端口编号,8,位,8,位,取值范围:,0,255,缺省值:,128,Page,15,/53,100M,STP,选择根端口举例,在非根桥上, 选择一个根端口(,RP,),A,B,C,优先级:,4096MAC,地址:,000d.2800.b100,优先级:,32768MAC,地址:,000d.2800.b101,优先级:,32768MAC,地址:,000d.2800.b102,Root Bridge,下一步:选择指定端口,100M,100M,Root Port,Root Port,在,B,和,C,上,到达,A,最近的端口是,B,和,C,的根端口,Page,16,/53,选择指定端口的依据,在每个网段上,选择,1,个指定端口,根桥上的端口全是指定端口,非根桥上的指定端口:,根路径成本最低,端口所在的网桥的,ID,值较小,端口,ID,值较小,Page,17,/53,STP,选择指定端口举例,在每个网段选择,1,个指定端口(,DP,),100M,A,B,C,优先级:,4096MAC,地址:,000d.2800.b100,优先级:,32768MAC,地址:,000d.2800.b101,优先级:,32768MAC,地址:,000d.2800.b102,Root Bridge,100M,100M,Root Port,这个端口既不是根端口,也不是指定端口,,STP,将这个端口阻塞(,Block,),在这个网段上,,B,的网桥,ID,较小,所以,B,上的端口为指定端口,DP,DP,DP,根网桥上的端口都是指定端口,Page,18,/53,STP,计算结果,经过,STP,计算,最终的逻辑结构为无环拓朴,100M,A,B,C,优先级:,32768MAC,地址:,000d.2800.b101,优先级:,32768MAC,地址:,000d.2800.b102,100M,优先级:,4096MAC,地址:,000d.2800.b100,备份线路,Page,19,/53,STP,举例,D,C,A,B,BID,:,32768,000d.2800.b100,BID,:,32768,000d.2805.c100,BID,:,32768,000d.2810.d100,BID,:,32768,000d.2811.e100,100M,100M,100M,100M,100M,Root Bridge,RP,RP,RP,DP,DP,DP,Block,Page,20,/53,经过,STP,计算后的逻辑拓朴,D,C,A,B,BID,:,32768,000d.2800.b100,BID,:,32768,000d.2805.c100,BID,:,32768,000d.2810.d100,BID,:,32768,000d.2811.e100,100M,100M,100M,Root Bridge,Page,21,/53,BPDU,(桥协议数据单元),交换机之间使用,BPDU,来交换,STP,信息,BPDU,Bridge Protocol Data Unit,桥协议数据单元,使用组播发送,BPDU,,组播地址为:,01-80-c2-00-00-00,BPDU,分为,2,种类型:,配置,BPDU, 用于生成树计算,拓朴变更通告(,TCN,),BPDU, 用于通告网络拓朴的变化,有没有想过,交换机怎么知道其他交换机的网桥,ID,?怎么知道哪个端口的根路径成本最小?,Page,22,/53,BPDU,包含的关键字段,字段,字节,作用,协议,ID,2,版本号,1,报文类型,1,标识是配置,BPDU,还是,TCN BPDU,标记域,1,根网桥,ID,8,用于通告根网桥的,ID,根路径成本,4,说明这个,BPDU,从根传输了多远,发送网桥,ID,8,发送这个,BPDU,网桥的,ID,端口,ID,2,发送报文的端口的,ID,报文老化时间,2,计时器值,用于说明生成树用多长时间完称它的每项功能,最大老化时间,2,访问时间,2,转发延迟,2,Page,23,/53,100M,STP,使用,BPDU,选择根网桥,2-1,100M,A,C,网桥,ID,:,32768.000d.2800.b101,网桥,ID,:,32768.000d.2800.b102,网桥,ID,:,4096.000d.2800.b100,字段,值,根网桥,ID,32768.000d.2800.b101,根路径成本,0,发送网桥,ID,32768.000d.2800.b101,端口,ID,xxxx,B,交换机启动时,假定自己是根网桥,在向外发送的,BPDU,中,根网桥,ID,字段填写自己的网桥,ID,100M,Page,24,/53,100M,100M,STP,使用,BPDU,选择根网桥,2-2,100M,A,C,字段,值,根网桥,ID,4096.000d.2800.b100,根路径成本,0,发送网桥,ID,4096.000d.2800.b100,端口,ID,xxxx,当接收到其他交换机发出的,BPDU,后,比较网桥,ID,,选择较小的添加到根网桥,ID,中,100M,A,字段,值,根网桥,ID,4096.000d.2800.b100,根路径成本,0,发送网桥,ID,32768.000d.2800.b101,端口,ID,xxxx,B,100M,网桥,ID,:,32768.000d.2800.b101,网桥,ID,:,32768.000d.2800.b102,网桥,ID,:,4096.000d.2800.b100,当全网所有的交换机接收到全部的,BPDU,并作比较后,就可以选择出唯一的一个根网桥,Page,25,/53,STP,使用,BPDU,计算根路径成本,2-1,100M,100M,100M,A,C,字段,值,根网桥,ID,4096.000d.2800.b100,根路径成本,0,发送网桥,ID,4096.000d.2800.b100,端口,ID,xxxx,A,B,根网桥发送根路径成本为,0,的,BPDU,100M,Root Bridge,网桥,ID,:,32768.000d.2800.b101,网桥,ID,:,32768.000d.2800.b102,网桥,ID,:,4096.000d.2800.b100,Page,26,/53,Root Bridge,A,STP,使用,BPDU,计算根路径成本,2-2,其他交换机接收到根网桥的,BPDU,后,在根路径成本上添加接收接口的路径成本,然后转发,100M,100M,100M,A,C,字段,值,根网桥,ID,4096.000d.2800.b100,根路径成本,19,发送网桥,ID,32768.000d.2800.b101,端口,ID,xxxx,100M,B,交换机保存接口的根路径成本到内存中,网桥,ID,:,32768.000d.2800.b101,网桥,ID,:,32768.000d.2800.b102,网桥,ID,:,4096.000d.2800.b100,Page,27,/53,生成树端口的状态,状态,用途,转发(,Forwarding,),发送和接收用户数据,学习(,Learning,),构建网桥表,侦听(,Listening,),构建“活动”拓朴,阻塞(,Blocking,),只接收,BPDU,禁用(,Disable,),强制关闭,交换机端口的,5,种,STP,状态,Page,28,/53,生成树计时器,20,秒,20,秒,15,秒,35,秒,15,秒,50,秒,阻断,倾听,转发,学习,最大寿命,转发延迟,转发延迟,交换机开机需要等待,30,秒时间开始转发数据,当某个正在使用的链路断掉,阻塞的端口需要,50,秒时间开始转发数据,Page,29,/53,阶段总结,如何确定哪些端口被,block,,哪些端口的状态为,forward,选举根网桥,选举根端口,选举指定端口,生成树端口的状态,生成树计时器,Page,30,/53,VLAN,与,STP,VLAN3,VLAN2,VLAN2,VLAN1,VLAN1,VLAN3,标准的生成树协议(,CST,)不考虑,VLAN,经过,STP,计算,会有一条链路被断开,Page,31,/53,PVST,(按,VLAN,生成树),PVST,是,Cisco,私有的,为每个,VLAN,构造一棵生成树,VLAN3,VLAN2,VLAN2,VLAN1,VLAN1,VLAN3,Page,32,/53,PVST+,PVST+,区域,PVST,区域,CST,区域,PVST,Cisco,私有,可以与,CST,互操作,用来连接,PVST,与,CST,区域,Page,33,/53,PVST,的配置,生成树自动运行,为什么还要进行配置?,Page,34,/53,配置网络中比较稳定的交换机为根网桥,利用,PVST,实现网络的负载分担,PVST,在实际中的应用,V1,V10,VLAN 1,5,的根网桥,VLAN 6,10,的根网桥,V1,V10,V1,V10,VLAN 1,5,的根端口,VLAN 1,5,数据的流向,VLAN 6,10,的根端口,VLAN 6,10,数据的流向,接入交换机,Page,35,/53,PVST,的配置命令,2-1,启用生成树,Switch(config)#spanning-tree vlan,vlan-list,设置根网桥,Switch(config)#spanning-tree vlan,vlan-list,root primary,|,secondary,修改网桥的优先级,Switch(config)#spanning-tree vlan,vlan-list,priority,Bridge-priority,设置为根网桥后,优先级变成,24576,优先级的值为,4096,的倍数,Page,36,/53,PVST,的配置命令,2-2,修改端口成本,Switch(config-if)#spanning-tree vlan,vlan-list,cost,cost,修改端口优先级,Switch(config-if)#spanning-tree vlan,vlan-list,port-priority,priority,配置上行速链路,Switch(config)#spanning-tree uplinkfast,配置端口速链路,Switch(config-if)#spanning-tree portfast,Page,37,/53,PVST,配置的查看,查看生成树的配置,Switch#show spanning-tree,查看某个,VLAN,的生成树详细信息,Switch#show spanning-tree vlan,vlan-id,detail,Page,38,/53,PVST,配置实例,11-1,C,A,B,D,Port 24,Port 24,Port 23,Port 23,Port 22,Port 23,Port 23,Port 22,Port 22,Port 22,32768.000d.28bf.4b40,32768.0013.6007.6a00,32768.000d.2861.b100,32768.000d.28bf.1140,缺省情况下的,STP,Root Bridge,Block,希望的配置结果,Vlan 1- 4,Vlan 1- 4,Vlan 1- 2,的根网桥,Vlan 3- 4,的根网桥,Page,39,/53,PVST,配置实例,11-2,配置,SwA,为,VLAN 1,和,2,的根网桥,SwA(config)#spanning-tree vlan 1 root primary,SwA(config)#spanning-tree vlan 2 root primary,配置,SwB,在,VLAN 3,和,4,中优先级为,4096,SwB(config)#spanning-tree vlan 3 priority 4096,SwB(config)#spanning-tree vlan 4 priority 4096,Page,40,/53,PVST,配置实例,11-3,查看配置结果,SwB# show spanning-tree,VLAN0001,Spanning tree enabled protocol ieee,Root ID Priority 24577,Address 000d.28bf.4b40,Cost 19,Port 24 (FastEthernet0/24),Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Bridge ID Priority 32769 (priority 32768 sys-id-ext 1),Address 0013.6007.6a00,Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Aging Time 300,Interface Role Sts Cost Prio.Nbr Type,- - - - - -,Fa0/22 Altn BLK 19 128.22 P2p,Fa0/23 Altn BLK 19 128.23 P2p,Fa0/24 Root FWD 19 128.24 P2p,根网桥的信息,自己的信息,本地接口的信息,VLAN 1,的根网桥为,SwA,,优先级为,24576,VLAN ID,端口,22,和,23,阻塞,,24,为根端口,VLAN 2,的生成树信息,Page,41,/53,PVST,配置实例,11-4,VLAN0002,Spanning tree enabled protocol ieee,Root ID Priority 24578,Address 000d.28bf.4b40,Cost 19,Port 24 (FastEthernet0/24),Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Bridge ID Priority 32770 (priority 32768 sys-id-ext 2),Address 0013.6007.6a00,Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Aging Time 300,Interface Role Sts Cost Prio.Nbr Type,- - - - - -,Fa0/22 Altn BLK 19 128.22 P2p,Fa0/23 Altn BLK 19 128.23 P2p,Fa0/24 Root FWD 19 128.24 P2p,Page,42,/53,PVST,配置实例,11-5,C,D,Port 24,Port 24,Port 23,Port 23,Port 22,Port 23,Port 23,Port 22,Port 22,Port 22,24576.000d.28bf.4b40,32768.0013.6007.6a00,32768.000d.2861.b100,32768.000d.28bf.1140,VLAN 1-2,的逻辑拓朴,Vlan 1- 4,Vlan 1- 4,Vlan 1- 2,的根网桥,B,A,Page,43,/53,PVST,配置实例,11-6,查看配置结果(,VLAN 3,4),SwA#show spanning-tree,VLAN0003,Spanning tree enabled protocol ieee,Root ID Priority 4099,Address 0013.6007.6a00,Cost 19,Port 24 (FastEthernet0/24),Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Bridge ID Priority 32771 (priority 32768 sys-id-ext 3),Address 000d.28bf.4b40,Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Aging Time 300,Interface Role Sts Cost Prio.Nbr Type,- - - - - -,Fa0/22 Altn BLK 19 128.22 P2p,Fa0/23 Altn BLK 19 128.23 P2p,Fa0/24 Root FWD 19 128.24 P2p,VLAN 4,的生成树信息,Page,44,/53,PVST,配置实例,11-7,VLAN0004,Spanning tree enabled protocol ieee,Root ID Priority 4100,Address 0013.6007.6a00,Cost 19,Port 24 (FastEthernet0/24),Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Bridge ID Priority 32772 (priority 32768 sys-id-ext 4),Address 000d.28bf.4b40,Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Aging Time 300,Interface Role Sts Cost Prio.Nbr Type,- - - - - -,Fa0/22 Altn BLK 19 128.22 P2p,Fa0/23 Altn BLK 19 128.23 P2p,Fa0/24 Root FWD 19 128.24 P2p,Page,45,/53,PVST,配置实例,11-8,C,D,Port 24,Port 24,Port 23,Port 23,Port 22,Port 23,Port 23,Port 22,Port 22,Port 22,32768.000d.28bf.4b40,4096.0013.6007.6a00,32768.000d.2861.b100,32768.000d.28bf.1140,VLAN 3-4,的逻辑拓朴,Vlan 1- 4,Vlan 1- 4,Vlan 3- 4,的根网桥,B,A,Page,46,/53,PVST,配置实例,11-9,配置交换机,C,上连接主机的端口为速端口,SwC(config)#interface range fastEthernet 0/1 - 20,SwC(config-if-range)#spanning-tree portfast,%Warning: portfast should only be enabled on ports connected to a single,host. Connecting hubs, concentrators, switches, bridges, etc. to this,interface when portfast is enabled, can cause temporary bridging loops.,Use with CAUTION,%Portfast will be configured in 20 interfaces due to the range command,but will only have effect when the interfaces are in a non-trunking mode.,Page,47,/53,PVST,配置实例,11-10,在交换机,C,上配置上行速链路,SwC(config)#spanning-tree uplinkfast,Page,48,/53,PVST,配置实例,11-11,配置了上行速链路后查看生成树信息,SwC#show spanning-tree,VLAN0001,Spanning tree enabled protocol ieee,Root ID Priority 24577,Address 000d.28bf.4b40,Cost 3019,Port 23 (FastEthernet0/23),Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Bridge ID Priority 49153 (priority 49152 sys-id-ext 1),Address 000d.2861.b100,Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec,Aging Time 300,Uplinkfast enabled,Interface Role Sts Cost Prio.Nbr Type,- - - - - -,Fa0/22 Altn BLK 3019 128.22 P2p,Fa0/23 Root FWD 3019 128.23 P2p,根路径成本增加了,3000,网桥优先级变成了,49152,端口,22,从转发变为阻塞,端口的路径成本为,3019,STP,配置演示,Page,49,/53,EthernetChannel,(以太通道),EthernetChannel,以太通道,多条线路负载均衡,带宽提高,容错,当一条线路失效时,其他线路通信,不会丢包,4,条线路捆绑,当作一条线路使用;以太通道常用于骨干交换机之间的互联或接入交换机上连骨干交换机的线路,配置为以太通道的接口,必须物理特性相同,Page,50,/53,以太通道的配置,配置接口为以太通道模式,Switch(config)# interface range fastEthernet 0/1 2,Switch(config-if-range)#channel-group 1 mode on,Creating a port-channel interface Port-channel 1,B,A,f0/1,f0/3,f0/2,f0/4,要捆绑在一起的端口,以太通道的组号,Page,51,/53,以太通道配置的验证,查看以太通道的配置,Switch# show etherchannel,1,summary,Flags: D - down,P - in port-channel,I - stand-alone s - suspended,H - Hot-standby (LACP only),R - Layer3,S - Layer2,U -,in use,f - failed to allocate aggregator,u - unsuitable for bundling,w - waiting to be aggregated,d - default port,Number of channel-groups in use: 1,Number of aggregators: 1,Group Port-channel Protocol Ports,-+-+-+-,1 Po1(,SU,) - Fa0/23(,P,) Fa0/24(,P,),Page,52,/53,本节总结,STP,协议,算法,防止广播风暴,STP,的,功能,EtherChannel,STP,的工作原理,PVST,BPDU,包,生成树端口的状态,工作原理,配置,3,个步骤:,选择根网桥,选择根端口,选择指定端口,用来交换生成树的信息,主要包含:,根网桥,ID,根路径成本,网桥,ID,端口,ID,转发,学习,侦听,阻塞,禁用,每,VLAN,生成树,为网络选择一个稳定的交换机作为根网桥,利用,PVST,实现负载分担,配置上行速链路,配置速端口,Page,53,/53,实验,任务,配置交换机的优先级,实现网络的负载分担,并配置骨干交换机之间的,EtherChannel,C,D,Port 1,2,Port 1,2,Port 23,Port 23,Port 22,Port 23,Port 23,Port 22,Port 22,Port 22,Vlan 1- 4,Vlan 1- 4,Vlan 1- 2,的根网桥,B,A,Vlan 3- 4,的根网桥,
展开阅读全文