实验3-1 配置STP
- 格式:pptx
- 大小:248.15 KB
- 文档页数:12
STP实验配置在上面的拓扑中有两个环,分别是A、B之间和B、C、D之间,STP默认是在VLAN1上打开的,所有我们先分别在A、B、C、D上查看:#show spanning-tree 我们可以发现目前根网桥是A,因为A的网桥ID最小,B的fa1/1接口和D的fa1/15接口被阻塞,分析一下为什么,并想一想根接口和指定接口分别是哪些。
一、STP基本配置:1、配置根网桥:a、在B上:(config)#spanning-tree vlan 1 root primary 配置B为VLAN1的根网桥b、在A上:(config)#spanning-tree vlan 1 root secondary 配置A为VLAN1的备份根网桥分别在A、B、C、D上查看:#show spanning-tree发现B已经成为VLAN1的根,优先级变为8192(2950交换机上会变为24576),A的优先级变为16384(2950交换机上会变为28672),现在阻塞接口是哪些,想一想。
2 、配置网桥优先级:在C上:(config)#spanning-tree vlan 1 priority 4096 配置C在VLAN 1中优先级为4096 分别在A、B、C、D上查看:#show spanning-tree发现C已经成为VLAN1新的根,优先级为4096(2950交换机上优先级是4096的倍数),在STP中谁的网桥ID最小谁就将成为根。
现在阻塞接口是哪些,想一想。
3、配置接口成本:现在由于C是根,所以我们通过show spanning-tree可以知道D的接口fa1/15是根接口,而fa1/9被阻塞了在D上:(config)#inter fa1/15(config- if)#spanning-tree vlan 1 cost 50 配置接口fa1/15在vlan 1中的成本为50在D上查看:#show spanning-tree发现D的接口fa1/15成本已经变为50(默认为19),根接口变成了fa1/9,而fa1/15被阻塞了,想想为什么4、配置接口优先级:现在由于C是根,所以我们通过show spanning-tree可以知道A的接口fa1/0是根接口,而fa1/1被阻塞了注意:在B上:(config)#inter fa1/1(config- if)#spanning-tree vlan 1 port-priority 64配置接口fa1/1在vlan 1中的优先级为64 在B上查看:#show spanning-tree 发现B的接口fa1/1优先级已经变为64(默认为128)在A上查看:#show spanning-tree 发现A的根接口变成了fa1/1,而fa1/0被阻塞了,想想为什么二、PVST配置:先重启交换机,然后创建VLAN,配置中继,A不打开1、B的配置:#vlan database 进入VLAN数据库(vlan )#vlan 2 创建vlan2(vlan )#vlan 3 创建vlan3(vlan )#vlan 4 创建vlan4(vlan )#exit 保存退出(config)#inter fa1/8(config- if)#switchport mode trunk 把接口fa1/8配为中继模式(config)#inter fa1/9(config- if)#switchport mode trunk 把接口fa1/9配为中继模式2、C的配置:#vlan database 进入VLAN数据库(vlan )#vlan 2 创建vlan2(vlan )#vlan 3 创建vlan3(vlan )#vlan 4 创建vlan4(vlan )#exit 保存退出(config)#inter fa1/8(config- if)#switchport mode trunk 把接口fa1/8配为中继(config)#inter fa1/15(config- if)#switchport mode trunk 把接口fa1/15配为中继3、D的配置:#vlan database 进入VLAN数据库(vlan )#vlan 2 创建vlan2(vlan )#vlan 3 创建vlan3(vlan )#vlan 4 创建vlan4(vlan )#exit 保存退出(config)#inter fa1/9(config- if)#switchport mode trunk 把接口fa1/9配为中继模式(config)#inter fa1/15(config- if)#switchport mode trunk 把接口fa1/15配为中继模式现在分别在B、C、D上把VLAN2、3、4的STP打开:(config)#spanning-tree vlan 2(config)#spanning-tree vlan 3(config)#spanning-tree vlan 4分别在B、C、D上查看:#show spanning-tree现在VLAN1、2、3、4中,B是根网桥,阻塞接口都是交换机D的fa1/15,那么C 的所有流量都从fa1/8走,D的所有流量都从fa1/9走,没有做到负载均衡。
配置配置PVST+说明:以上图为例,配置PVST+,默认交换机上都配置有VLAN 10,VLAN 20,VLAN 30,VLAN 40,要求控制SW1与SW4之间的流量路径为VLAN 10和VLAN 20从SW1—SW2—SW4,VLAN 30和VLAN 40从SW1—SW3—SW4。
注:默认为PVST+,所以STP版本不用改。
1.配置各交换机优先级(只能为4096的整数倍)(1)配置SW1在所有VLAN的优先级为4096sw1(config)#spanning-tree vlan 10-40 priority 4096(2)配置SW2在所有VLAN的优先级24576sw2(config)#spanning-tree vlan 10-40 priority 24576(3)配置SW3在所有VLAN的优先级32768sw3(config)#spanning-tree vlan 10-40 priority 32768(4)配置SW4在所有VLAN的优先级32768sw4(config)#spanning-tree vlan 10-40 priority 327682.配置SW2的F0/20的端口优先级(必须为16的整数倍)(1)在所有VLAN将SW2的F0/20的端口优先级配置为112 sw2(config)#int f0/20sw2(config-if)#spanning-tree vlan 10-40 port-priority 1123.查看根交换机(1)查看根交换机SW1说明:因为现在4个VLAN的配置是一样的,结果也是一样的,所以只提供一个VLAN的结果:sw1#sh spanning-tree(输出被省略)VLAN0010Spanning tree enabled protocol ieeeRoot ID Priority 4106Address 001a.6c6f.fb00This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 4106 (priority 4096 sys-id-ext 10)Address 001a.6c6f.fb00Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface Role Sts Cost Prio.Nbr Type---------------- ---- --- --------- -------- --------------------------------Fa0/23 Desg FWD 19 128.25 P2p(输出被省略)sw1#说明:从结果中看出,SW1手工配置的优先级为4096,但由于Extended SystemID功能,所以优先级加上了VLAN号码10,结果优先级变为4106,因为优先级在网络中数字最小,所以自己就是当前网络的根交换机。
STP配置
一、目的
通过完成本实验的任务,使学生熟悉stp技术原理,掌握stp的基本配置方法。
学会与人合作、严谨细致的工作态度,同时拓展相应的信息收集和应用能力、思考和解决问题的能力。
二、设备与器件
1.剥线钳、工具刀
2.5类或6类双绞线
3.测试台或测线仪
4.计算机
5.Cisco 2950 交换机
三、工作内容
1.STP的技术原理认知
2.STP的基本配置
四、工作步骤与要求
1.绘制拓扑结构
2.检查配置
[switch1]#show spanning-tree
[switch2]#show spanning-tree
[switch3]#show spanning-tree
3.分析原因
SW1:
32768.000C.2988.5976
SW2:SW3:
32768.000C.2187.9744 32768.000C.1229.7843
SW1:
0/1口对应SW2的0/2口,0/2口对应SW3的0/1口
SW2:
0/1口对应SW3的0/3口,0/2口对应SW1的0/1口
SW3:
0/1口对应SW1的0/2口,0/3口对应SW2的0/1口
通过选举和cost值比较:
其中SW3为根交换机,SW1的0/2口和SW2的0/1口为根端口,SW2的0/2口、SW3的0/1口、SW3的0/3口为指定端口,SW1的0/1口为阻塞端口。
STP (生成树协议) 是一个二层管理协议。
在一个扩展的局域网中参预STP 的所有交换机之间通过交换桥协议数据单元bpdu (bridge protocol data unit)来实现;为稳定的生成树拓扑结构选择一个根桥;为每一个交换网段选择一台指定交换机;将冗余路径上的交换机置为blocking,来消除网络中的环路。
IEEE 802. 1d 是最早关于STP 的标准,它提供了网络的动态冗余切换机制。
STP 使您能在网络设计中部署备份路线,并且保证:* 在主路线正常工作时,备份路线是关闭的。
* 当主路线浮现故障时自动使能备份路线,切换数据流。
rSTP (rapid spanning tree protocol)是STP 的扩展,其主要特点是增加了端口状态快速切换的机制,能够实现网络拓扑的快速转换。
1.1 设置STP 模式使用命令config spanning-tree mode 可以设置STP 模式为802. 1d STP 或者802. 1w rSTP.1.2 配置STP交换机中默认存在一个default STP 域。
多域STP 是扩展的802. 1d,它允许在同一台交换设备上同时存在多个STP 域,各个STP 域都按照802. 1d 运行,各域之间互不影响。
它提供了一种能够更为灵便和稳定网络环境,基本实现在vlan 中计算生成树。
1.2.1 创建或者删除STP利用命令create STPd 和delete STPd 可以创建或者删除STP.缺省的default STP 域不能手工创建和删除。
1.2.2 使能或者关闭STP交换机中STP 缺省状态是关闭的。
利用命令config STPd 可以使能或者关闭STP.1.2.3 使能或者关闭指定STP 的端口交换机中所有端口默认都是参预STP 计算的。
使用命令config STPd port 可以使能或者关闭指定的STP 端口。
1.2.4 配置STP 的参数运行某个指定STP 的STP 协议后,可以根据具体的网络结构调整该STP 的一些参数。
ensp实验:配置stp需求:LSW1为主根桥、LSW2为备份根桥;端⼝:DP ->指定端⼝RP ->根端⼝AP ->备份端⼝(被阻塞)1.准备设置将4个交换机的STP类型设置成STP(华为交换机默认的STP类型为MSTP)将链路的开销标准设定为1988(1988标准看起来⽅便,华为交换机默认的链路开销标准为:dot1t)1)配置LSW1syssys SW1stp mode stpstp pathcost-standard dot1d-19982)配置其它三个交换机命令和上⾯⼀模⼀样;2.配置主/备根桥根桥是根据交换机的pid选出来的;pid由优先级和mac地址组成,先⽐较优先级、再⽐较mac地址,选⼩的为根桥;mac地址⽆法改变,但优先级可以设置,优先级默认为:32768;优先级的step = 4096(也就是说,优先级设置时,必须是4096的倍数)因此只需要将LSW1和LSW2的优先级设为最⼩和第⼆⼩即可;有两种命令可以实现:1】stp prority 4096 ->直接设置优先级2】stp root primary/secondary ->设置交换机为主/备根桥;(这个命令本质上是将主根桥优先级设为0,备根桥优先级设为4096)这⾥选⽤⽅式2;1)配置LSW1将LSW1设置为主根桥stp root primary查看stp信息:可以看到LSW1的优先级变为了02)配置LSW2将LSW2设置为备根桥stp root secondary输⼊命令:dis stp可以看到:LSW2的优先级被设置成了4096;⽬前的主根桥的PID就是LSW1的PID;并且LSW2到根桥LSW1的根路劲开销 = 19,因为LSW1-LSW2之间是通过E⼝连接,E⼝是100M的,根据d1988标准,开销=19;LSW1-LSW3之间通过G⼝相连,G⼝是1000M,开销 = 4;3)分析端⼝类型1】分析LSW1LSW1是根断桥,连个端⼝都是指定端⼝DP;2】分析LSW2LSW2有两个端⼝;LSW2的1端⼝直接和根桥相连,根路径开销RPC⼩于2端⼝,因此被选为LSW2的根端⼝RP;LSW2的2号端⼝类型判断:lsw2的2号端⼝和lsw3相连,lsw2-lsw3这条链路中需要选出指定端⼝;⾸先⽐较根路径开销:lsw3和lsw1相连,lsw3是g⼝,g⼝是1000M,根据d1988标准,根路径开销 = 4;lsw2和lsw1相连,lsw2是e⼝,e⼝是100M,根路径开销 = 19;因此,在lsw2-lsw3这条链路中,lsw3的端⼝被选为了指定端⼝DP;导致lsw2的2号端⼝既不是RP也不是DP,因此只能是备⽤端⼝AP;验证:dis stp brief3】分析LSW3lsw3的1号接⼝直接和根桥相连,RPC最⼩,被选为根端⼝RP;lsw3的2号接⼝,因为RPC⼩于lsw2的2号接⼝,被选为指定端⼝DP;lsw3的3、4号接⼝都和lsw4相连,在其所属的链路中因为RPC⽐lsw4端⼝的⼩,被选为DP;4】分析LSW4lsw4有两个端⼝,⾸先需要在这两个端⼝之间选出根端⼝;lsw4的1、2号端⼝都和lsw3相连,根路径开销RPC相同、对端BID相同;然后⽐较对端PID:lsw4的1号端⼝和lsw3的3号端⼝相连,对端pid = 3;lsw4的2号端⼝和lsw3的4号端⼝相连,对端pid = 4;对端pid⼩的优先,因此lsw4的1号端⼝被选为根端⼝RP;lsw4的2号端⼝,既不是RP也不是DP,被当成备⽤端⼝AP;5)接⼝类型图3.阻塞接⼝互换1)需求⽬前有两个阻塞的备⽤接⼝:LSW4的2接⼝、LSW2的2接⼝;需要将阻塞接⼝换为:LSW4的1接⼝、LSW3的2接⼝;2)LSW2和LSW3的阻塞端⼝互换lsw2的2⼝和lsw3的2⼝在⼀条链路中;这两个接⼝被选为DP的依据是lsw3⼝的2⼝RPC=4,⼩于lsw2的2⼝RPC=19;因此想要互换端⼝类型,只需要实现:lsw2的RPC⼩于lsw3的RPC即可;实现⽅式:将lsw3的2⼝RPC改为20;lsw3的2⼝的RPC来⾃于lsw3的1⼝从lsw1接收的BPDU;RPC = LSW1的RPC + lsw3的1⼝的PathCost = 0 + 4 = 4;lsw1是根桥,根桥到⾃⼰的RPC = 0 ;lsw3的1⼝是G⼝,G⼝是1000M⼝,根据d1988标准,1000M⼝的开销 = 4;配置LSW3:为了让RPC = 20,可以⼿动⽤命令设置lsw3的1⼝的cost为20int g0/0/1stp cost 20验证:lsw3的2⼝将变成APlsw2的2⼝变成DP3)LSW4的1⼝和2⼝互换1】⽅法⼀为了让LSW4的阻塞端⼝互换,只需要实现在LSW4选根端⼝RP时,将2⼝选为根端⼝;选根端⼝⾸先⽐较的是根路径开销RPC;lsw4的两个⼝都和lsw3相连,来⾃lsw3的PBDU的RPC相等;lsw4的1⼝的RPC = lsw3的BPDU的RPC + lsw4的1⼝开销;lsw4的2⼝的RPC = lsw3的BPDU的RPC + lsw4的2⼝开销;1、2⼝的开销默认为4(G⼝1000M)需要将lsw4的1⼝的开销适当改⼤即可;2】⽅法⼆lsw4选根端⼝时,⾸先⽐较RPC;RPC⼀样则⽐较对端BID;(这⾥由于都是⽤的同⼀个对端BID,改了也⽆法达到⽬的)对端BID⼀样则⽐较对端PID,可以通过修改对端PID来实现;lsw4的1⼝对端是lsw3的3⼝;lsw4的2⼝对端是lsw3的4⼝;查看lsw3的3⼝PID:dis stp int g0/0/3可以看到:lsw3的3⼝pid = 128.3;(优先级为默认的128,端⼝编号3)lsw3的4⼝pid = 123.4;有两种⽅式:将lsw3的3⼝优先级改⼤;将lsw3的4⼝优先级改⼩;配置lsw3:这⾥⽤第⼆种⽅式;注意:接⼝优先级的setp = 16(也就是说接⼝优先级为16的倍数)int g0/0/4stp port priority 16验证效果:lsw4的1接⼝变为备⽤接⼝APlsw4的2接⼝变为根接⼝RP。
实训1:交换机STP、RSTP配置 2学会交换机主链路和冗余链路的配置学会交换机STP和RSTP的配置通过配置交换机STP优先级指定网络中的根交换机。
交换机的冗余链路一、实训目的:1. 学会交换机主链路和冗余链路的配置2. 学会交换机STP和RSTP的配置二、实训器材:1. S2126G二台,微机两台2. 直通双绞跳线4根。
三、实训内容、步骤及数据记录1. 实训要点:(1)交换机缺省生成树状态是开着的,模式为MSTP。
(2)STP对应标准:IEEE802.1dRSTP 对应标准 IEEE 802.1wMSTP 对应标准 IEEE 802.1s(VLAN环境下的生成树协议)(3)相关的命令:开启生成树协议:sw(config)#spanning-tree设置生成树模式:sw(config)#spanning-tree mode {stp|rstp|mstp}设置交换机的优先级:Sw(config)# spanning-tree priority <0-61440> ;0或4096的整倍数,默认值是32768设置端口的优先级:Sw(config)#spanning-tree port-priority <0-240>;0或16的整倍数,默认值是128以上命令都可以在前面加no 恢复为默认值。
显示生成树的状态:sw#show spanning-tree显示端口的生成树状态: sw#show spanning-tree interface fastethernet 端口号2、相关理论: 为了提高网络的安全稳定性,网络中通常会提供冗余链路,但是冗余链路会形成物理环路,从而引发广播风暴、MAC 地址表不稳定等问题,甚至导致网络瘫痪。
因此,在网络中运行生成树技术,在提供冗余链路同时解决环路问题。
生成树技术在网络中采用生成树算法,通过交换机优先级等信息选举出一台根交换机,再以根交换机为根节点在网络中形成一棵没有环路的树,从而解决链路环路引发的问题。
STP配置命令目录第1章 STP配置命令 (1)1.1 SSTP配置命令 (1)1.1.1 spanning-tree mode (1)1.1.2 spanning-tree sstp priority (2)1.1.3 spanning-tree sstp hello-time (2)1.1.4 spanning-tree sstp max-age (3)1.1.5 spanning-tree sstp forward-time (4)1.1.6 spanning-tree sstp cost (5)1.1.7 spanning-tree cost (6)1.1.8 spanning-tree sstp port-priority (6)1.1.9 spanning-tree port-priority (7)1.1.10 spanning-tree designated-auto (8)1.1.11 show spanning-tree (9)1.2 VLAN STP配置命令 (10)1.2.1 spanning-tree mode pvst (10)1.2.2 spanning-tree vlan (11)1.2.3 spanning-tree vlan priority (12)1.2.4 spanning-tree vlan forward-time (12)1.2.5 spanning-tree vlan max-age (13)1.2.6 spanning-tree vlan hello-time (14)1.2.7 spanning-tree vlan cost (15)1.2.8 spanning-tree vlan port-priority (16)1.2.9 show spanning-tree vlan (17)1.3 RSTP配置命令 (18)1.3.1 spanning-tree mode rstp (18)1.3.2 spanning-tree rstp forward-time (19)1.3.3 spanning-tree rstp hello-time (19)1.3.4 spanning-tree rstp max-age (20)1.3.5 spanning-tree rstp priority (21)1.3.6 spanning-tree rstp cost (21)1.3.7 spanning-tree rstp port-priority (22)1.3.8 spanning-tree rstp migration-check (23)第2章 MSTP配置命令 (24)2.1 MSTP配置命令 (24)2.1.1 spanning-tree mode mstp (24)2.1.2 spanning-tree mstp name (25)2.1.3 spanning-tree mstp revision (25)2.1.4 spanning-tree mstp instance (26)2.1.5 spanning-tree mstp root (27)2.1.6 spanning-tree mstp priority (28)2.1.7 spanning-tree mstp hello-time (29)2.1.8 spanning-tree mstp forward-time (29)2.1.9 spanning-tree mstp max-age (30)2.1.10 spanning-tree mstp diameter (31)2.1.11 spanning-tree mstp max-hops (32)2.1.12 spanning-tree mstp port-priority (32)2.1.13 spanning-tree mstp cost (33)2.1.14 spanning-tree mstp point-to-point (34)2.1.15 spanning-tree mstp mst-compatible (35)2.1.16 spanning-tree mstp migration-check (35)2.1.17 show spanning-tree mstp (36)2.1.18 show spanning-tree mstp region (37)2.1.19 show spanning-tree mstp detail (38)2.1.20 show spanning-tree mstp interface (40)第1章 STP配置命令1.1 SSTP配置命令1.1.1 spanning-tree mode命令描述spanning-tree mode {rstp|sstp}no spanning-tree mode配置spanning-tree运行模式,no命令禁止STP运行。
STP 的配置一、实验目标1、掌握启用和禁用STP的方法2、掌握修改交换机STP模式的方法3、掌握修改桥优先级,控制根桥选举的方法二、实验拓扑三、实验步骤1、配置STP并验证本实验中,S1和S2之间有两条链路。
在S1和S2上启用STP,并把S1配置为根桥。
<Quidway>system-viewEnter system view, return user view with Ctrl+Z.[Quidway]sysname S1[S1]stp mode stp[S1]stp root primary (此命令等同于:[S1]stp priority 0)<Quidway>system-viewEnter system view, return user view with Ctrl+Z.[Quidway]sysname S2[S2]stp mode stp[S2]stp root secondary(此命令等同于:[S2] stp priority 4096 )(1)执行display stp brief命令查看STP信息。
[S1]display stp brief记录:S1上E0/0/9的端口角色是(),转发状态是()。
S1上E0/0/10 的端口角色是(),转发状态是()。
[S2]display stp briefS2上E0/0/9的端口角色是(),转发状态是()。
S2上E0/0/10的端口角色是(),转发状态是()。
(2)执行display stp命令查看端口的STP状态。
<S1>display stp记录:S1的桥ID是(),STP的根桥的桥ID是();<S2>display stp记录:S2的桥ID是(),STP的根桥的桥ID是();从以上可知,()是STP的根桥。
(3)执行display stp Ethernet0/0/10,观察可以查看到哪些信息。
STP 技术实验目的: 熟悉掌握STP 配置,掌握STP 原理及选举过程设备说明: 使用小凡模拟器3640实验拓扑:SW 1SW 2SW 3f0/1f0/2f0/1f0/2f0/2f0/1实验步骤:基础配置:(1)把所有线路down 掉sw1(config)#int f0/1 //把SW1的f0/1端口downsw1(config-if)#shutdownsw1(config)#int f0/2 //把SW1的f02端口downsw1(config-if)#shutdownsw2(config)#int f0/1 //把SW2的f0/1端口downsw2(config-if)#shutdown(2)在sw1,sw2,sw3 都分别创建 vlan 10, vlan 20sw1#vlan database // 在sw1分别创建vlan 10 vlan 20sw1(vlan)#vlan 10sw1(vlan)#vlan 20Sw2#vlan database // 在sw2分别创建vlan 10 vlan 20sw2(vlan)#vlan 10sw2(vlan)#vlan 20Sw3#vlan database // 在sw3分别创建vlan 10 vlan 20Sw3(vlan)#vlan 10Sw3(vlan)#vlan 20(3) 把sw1,sw2,sw3 的f0/1,f0/2接口划入vlan 10sw1(config)#int f0/1sw1(config-if)#switchport access vlan 10 //把f0/1划属于vlan 10 sw1(config-if)#int f0/2sw1(config-if)#switchport access vlan 10 //把f0/2划属于vlan 10sw2(config)#int f0/1sw2(config-if)#switchport access vlan 10 //把f0/1划属于vlan 10 sw2(config-if)#int f0/2sw2(config-if)#switchport access vlan 10 //把f0/2划属于vlan 10sw3(config)#int f0/1sw3(config-if)#switchport access vlan 10 //把f0/1划属于vlan 10 sw3(config-if)#int f0/2sw3(config-if)#switchport access vlan 10 //把f0/2划属于vlan 10(3)查看配置信息Sw1sw1#show running-configBuilding configuration...Current configuration : 945 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname sw1!boot-start-markerboot-end-marker!!no aaa new-modelmemory-size iomem 5!!ip cefno ip domain lookup!!!!!!!!!!!!!!!!!!interface FastEthernet0/0!interface FastEthernet0/1switchport access vlan 10shutdown //f0/1,f0/2接口属于vlan 10 并且为down 状态!interface FastEthernet0/2switchport access vlan 10shutdown!interface FastEthernet0/3!interface FastEthernet0/4!interface FastEthernet0/5!interface FastEthernet0/6!interface FastEthernet0/7!interface FastEthernet0/8!interface FastEthernet0/9!interface FastEthernet0/10!interface FastEthernet0/11!interface FastEthernet0/12!interface FastEthernet0/13interface FastEthernet0/14!interface FastEthernet0/15!interface Vlan1no ip address!ip http server!!!!!!control-plane!!!!!!!!!line con 0line aux 0line vty 0 4!!endsw2sw2#show running-configBuilding configuration...Current configuration : 945 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!!boot-start-markerboot-end-marker!!no aaa new-modelmemory-size iomem 5!!ip cefno ip domain lookup!!!!!!!!!!!!!!!!!!interface FastEthernet0/0!interface FastEthernet0/1switchport access vlan 10shutdown //f0/1,f0/2接口属于vlan 10 并且为down 状态!interface FastEthernet0/2switchport access vlan 10shutdown!interface FastEthernet0/3!interface FastEthernet0/4!interface FastEthernet0/5 !interface FastEthernet0/6 !interface FastEthernet0/7 !interface FastEthernet0/8 !interface FastEthernet0/9 !interface FastEthernet0/10 !interface FastEthernet0/11 !interface FastEthernet0/12 !interface FastEthernet0/13 !interface FastEthernet0/14 !interface FastEthernet0/15 !interface Vlan1no ip address!ip http server!!!!!!control-plane!!!!!!!!!line con 0line aux 0line vty 0 4!!endsw3sw3#show running-configBuilding configuration...Current configuration : 945 bytes!version 12.4service timestamps debug datetime msecservice timestamps log datetime msecno service password-encryption!hostname sw3!boot-start-markerboot-end-marker!!no aaa new-modelmemory-size iomem 5!!ip cefno ip domain lookup!!!!!!!!!!!!!!!!!interface FastEthernet0/0!interface FastEthernet0/1switchport access vlan 10shutdown //f0/1,f0/2接口属于vlan 10 并且为down 状态!interface FastEthernet0/2switchport access vlan 10shutdown!interface FastEthernet0/3!interface FastEthernet0/4!interface FastEthernet0/5!interface FastEthernet0/6!interface FastEthernet0/7!interface FastEthernet0/8!interface FastEthernet0/9!interface FastEthernet0/10!interface FastEthernet0/11!interface FastEthernet0/12!interface FastEthernet0/13!interface FastEthernet0/14!interface FastEthernet0/15!interface Vlan1no ip address!ip http server!!!!!control-plane!!!!!!!!!line con 0line aux 0line vty 0 4!!end实验调试:(1)将sw1,sw2,sw3的f0/1 ,f0/2,f0/3接口打口sw1(config)#int f0/1sw1(config-if)#no shsw1(config-if)#int f0/2sw1(config-if)#no shsw2(config)#int f0/1sw2(config-if)#no shsw2(config-if)#int f0/2sw2(config-if)#no shsw3(config)#int f0/1sw3(config-if)#no shsw3(config-if)#int f0/2sw3(config-if)#no sh(2)在sw1,sw2,sw3 spanging-tree vlan 10Sw1:sw1#show spanning-tree briefVLAN10Spanning tree enabled protocol ieeeRoot ID Priority 32768 //根网桥ID 优先极为32768 默认值Address cc00.0bd8.0000 //MAC地址This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768 //网桥ID优先极为默认32768值Address cc00.0bd8.0000 //mac值与根网桥一样,证明SW1为根网桥Hello Time 2 sec Max Age 20 s ec Forward Dela y 15 s ec//hello时间为2秒//老化时间为20秒转发延时为15秒Aging Time 300Interface DesignatedName Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0bd8.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 32768 cc00.0bd8.0000 128.3//端口优先极//默认优先极//cost 值为19端口ID值sw2#show spanning-tree vlan 10VLAN10Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0bd8.0000Cost 19Port 2 (FastEthernet0/1)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768Address cc00.0c40.0000Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface DesignatedName Port ID Prio Cost Sts Cost Bridge ID Port ID-------------------- ------- ---- ----- --- ----- -------------------- -------FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0bd8.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 19 32768 cc00.0c40.0000 128.3sw3#show spanning-tree vlan 10 briefVLAN10Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0bd8.0000Cost 19Port 3 (FastEthernet0/2)Hello Time 2 sec Max Age 20 se c Forward Delay 15 secBridge ID Priority 32768Address cc00.0c88.0000Hello Time 2 sec Max Age 20 se c Forward Delay 15 secAging Time 300Interface DesignatedName Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------FastEthernet0/1 128.212819 BLK 19 32768 cc00.0c40.0000 128.3 FastEthernet0/2 128.3128 19 FWD 0 32768 cc00.0bd8.0000 128.3sw3#show spanning-tree int f0/1Port 2 (FastEthernet0/1) of VLAN10 is blocking //端口阻塞Port path cost 19, Port priority 128, Port Identifier 128.2.Designated root has priority 32768, address cc00.0bd8.0000Designated bridge has priority 32768, address cc00.0c40.0000Designated port id is 128.3, designated path cost 19Timers: message age 3, forward delay 0, hold 0Number of transitions to forwarding state: 0BPDU: sent 0, received 457sw3#show spanning-tree int f0/2Port 3 (FastEthernet0/2) of VLAN10 is forwarding //端口为转发状态Port path cost 19, Port priority 128, Port Identifier 128.3.Designated root has priority 32768, address cc00.0bd8.0000Designated bridge has priority 32768, address cc00.0bd8.0000Designated port id is 128.3, designated path cost 0Timers: message age 2, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 1, received 456总结: 最终sw1被选为根网桥,因为它的MAC值最小阻塞sw3的f0/1端口STP 收敛过程如下:BPDU有两种类型:1.配置BPDU2.拓扑变更BPDUSTP的时间参数:阻断20S侦听15S学习15S转发。