
深入理解生成树
原创
©著作权归作者所有:来自51CTO博客作者杭州驰哥的原创作品,谢绝转载,否则将追究法律责任

实验应用场景描述:
实验内容主要适合于对网络可靠性要求高的网络环境通过生成树协议和以太网通道的应用实现了网络的双核心和高可靠性,任何一台核心交换机出现故障无法运行或下层交换机和核心层交换机之间的连线出现故障都不会影响网络的正常运行.
实验使用命令:
1:spanning-tree vlan vlan—list ………启用生成树
2:spanning-tree vlan vlan-list root primary /secondary 配置交换机为根网桥
3:spanning-tree vlan vlan-list priority Bridge-priority
修改交换机的优先级
4. spanning-tree vlan vlan-list cost cost 修改端口成本优先级。
5. spanning-tree vlan vlan-list port-priority priority修改端口优先级。
6. spanning-tree uplinkfast 配置上行速链路
7. spanning-tree portfast 配置速端口
8. sh spanning-tree brief 查看生成树信息
实验步骤:
设置交换机A为VTP服务器模式其余为客户模式
设置交换机A为vlan 1.vlan2 的根网桥
设置交换机A和交换机B之间为以太网通道。
配置命令:
ena
vlan data
vtp domain benet
vtp ser
vlan 2
vlan 3
vlan 4
exit
conf t
host swA
int range f0/1 -2
no sh
swit mode trunk
channel-group 1 mode on
exit
int range f0/14 -15
no sh
swit mode trunk
exit
spanning-tree vlan 1 priority 4096
spanning-tree vlan 2 priority 4096
spanning-tree vlan 3 priority 8192
spanning-tree vlan 4 priority 8192
exit
wri
***************************************
1.1:操作命令及命令解释
设置交换机A为VTP服务器模式其余为客户模式
设置交换机A为vlan 1.vlan2 的根网桥
设置交换机A和交换机B之间为以太网通道。
配置命令:
ena
vlan data
vtp domain benet
vtp ser
vlan 2
vlan 3
vlan 4
exit
conf t
host swA
int range f0/1 -2
no sh
swit mode trunk
channel-group 1 mode on
exit
int range f0/14 -15
no sh
swit mode trunk
exit
spanning-tree vlan 1 priority 4096
spanning-tree vlan 2 priority 4096
spanning-tree vlan 3 priority 8192
spanning-tree vlan 4 priority 8192
exit
wri
验证结果
swA#sh spanning-tree bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0a 34.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4096
Address cc00.0a 34.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 0 4096 cc00.0a 34.0000 128.15
FastEthernet0/15 128.16 128 19 FWD 0 4096 cc00.0a 34.0000 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0a 34.0000 129.65
VLAN2
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0a 34.0001
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4096
Address cc00.0a 34.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 0 4096 cc00.0a 34.0001 128.15
FastEthernet0/15 128.16 128 19 FWD 0 4096 cc00.0a 34.0001 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0a 34.0001 129.65
VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0874.0002
Cost 12
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0a 34.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 12 32768 cc00.0a 34.0002 128.15
FastEthernet0/15 128.16 128 19 FWD 12 32768 cc00.0a 34.0002 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0874.0002 129.65
VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0874.0003
Cost 12
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0a 34.0003
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 12 32768 cc00.0a 34.0003 128.15
FastEthernet0/15 128.16 128 19 FWD 12 32768 cc00.0a 34.0003 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0874.0003 129.65
设置交换机B为vlan3.vlan4的根网桥
配置命令:
ena
vlan data
vtp domain benet
vtp client
exit
conf t
host swB
int range f0/1 -2
no sh
swit mode trunk
channel-group 1 mode on
exit
int range f0/14 -15
no sh
swit mode trunk
exit
spanning-tree vlan 1 priority 8192
spanning-tree vlan 2 priority 8192
spanning-tree vlan 3 priority 4096
spanning-tree vlan 4 priority 4096
exit
wri
验证结果
swB#sh vtp s
VTP Version : 2
Configuration Revision : 1
Maximum VLANs supported locally : 256
Number of existing VLANs : 8
VTP Operating Mode : Client
VTP Domain Name : benet
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0xD2 0x0F 0xBC 0x87 0xB8 0xE8 0x43 0x98
Configuration last modified by 0.0.0 .0 at 3-1-02 00:00:38
swB#sh vlan-s
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
2 VLAN0002 active
3 VLAN0003 active
4 VLAN0004 active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
swB#sh spanning-tree bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0a 34.0000
Cost 12
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0874.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 12 32768 cc00.0874.0000 128.15
FastEthernet0/15 128.16 128 19 FWD 12 32768 cc00.0874.0000 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0a 34.0000 129.65
VLAN2
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0a 34.0001
Cost 12
Port 321 (Port-channel1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0874.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 12 32768 cc00.0874.0001 128.15
FastEthernet0/15 128.16 128 19 FWD 12 32768 cc00.0874.0001 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0a 34.0001 129.65
VLAN3
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0874.0002
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4096
Address cc00.0874.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 0 4096 cc00.0874.0002 128.15
FastEthernet0/15 128.16 128 19 FWD 0 4096 cc00.0874.0002 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0874.0002 129.65
VLAN4
Spanning tree enabled protocol ieee
Root ID Priority 4096
Address cc00.0874.0003
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4096
Address cc00.0874.0003
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 19 FWD 0 4096 cc00.0874.0003 128.15
FastEthernet0/15 128.16 128 19 FWD 0 4096 cc00.0874.0003 128.16
Port-channel1 129.65 128 12 FWD 0 4096 cc00.0874.0003 129.65
设置接入层交换机上行速链路和上行速端口
配置命令:
ena
vlan data
vtp domain benet
vtp client
exit
conf t
host swd
int range f0/14 -15
no sh
swit mode trunk
exit
spanning-tree uplinkfast
int range f0/1 -13
spanning-tree portfast
exit
exit
wri
验证结果
swc#sh spanning-tree bri
VLAN1
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0a 34.0000
Cost 3019
Port 15 (FastEthernet0/14)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.066c .0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 FWD 0 4096 cc00.0a 34.0000 128.15
FastEthernet0/15 128.16 128 3019 BLK 12 32768 cc00.0874.0000 128.15
VLAN2
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0a 34.0001
Cost 3019
Port 15 (FastEthernet0/14)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.066c .0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 FWD 0 4096 cc00.0a 34.0001 128.15
FastEthernet0/15 128.16 128 3019 BLK 12 32768 cc00.0874.0001 128.15
VLAN3
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0874.0002
Cost 3019
Port 16 (FastEthernet0/15)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.066c .0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 BLK 12 32768 cc00.0a 34.0002 128.15
FastEthernet0/15 128.16 128 3019 FWD 0 4096 cc00.0874.0002 128.15
VLAN4
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0874.0003
Cost 3019
Port 16 (FastEthernet0/15)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.066c .0003
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 BLK 12 32768 cc00.0a 34.0003 128.15
FastEthernet0/15 128.16 128 3019 FWD 0 4096 cc00.0874.0003 128.15
可以看到在交换机C上VLAN1.VLAN2的f0/15端口被阻塞。在VLAN3.VLAN4的时候f0/14端口被阻塞。
swd#sh spanning-tree bri
VLAN1
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0a 34.0000
Cost 3019
Port 16 (FastEthernet0/15)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.0764.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 BLK 12 32768 cc00.0874.0000 128.16
FastEthernet0/15 128.16 128 3019 FWD 0 4096 cc00.0a 34.0000 128.16
VLAN2
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0a 34.0001
Cost 3019
Port 16 (FastEthernet0/15)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.0764.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 BLK 12 32768 cc00.0874.0001 128.16
FastEthernet0/15 128.16 128 3019 FWD 0 4096 cc00.0a 34.0001 128.16
VLAN3
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0874.0002
Cost 3019
Port 15 (FastEthernet0/14)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.0764.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 FWD 0 4096 cc00.0874.0002 128.16
FastEthernet0/15 128.16 128 3019 BLK 12 32768 cc00.0a 34.0002 128.16
VLAN4
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 4096
Address cc00.0874.0003
Cost 3019
Port 15 (FastEthernet0/14)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc00.0764.0003
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/14 128.15 128 3019 FWD 0 4096 cc00.0874.0003 128.16
FastEthernet0/15 128.16 128 3019 BLK 12 32768 cc00.0a 34.0003 128.16
可以看出在交换机D上,在VLAN1.VLAN2的端口F0/14端口被阻塞,在VLAN3。VLAN4的端口F0/15端口被阻塞。
swd#sh run b
Building configuration
Current configuration
version 12.4
service timestamps deb
service timestamps log
no service password-en
hostname swd
boot-start-marker
boot-end-marker
no aaa new-model
memory-size iomem 5
ip cef
spanning-tree uplinkfa
interface FastEthernet
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
spanning-tree portfas
interface FastEthernet
switchport mode trunk
spanning-tree portfas
interface FastEthernet
switchport mode trunk
interface Vlan1
no ip address
ip http server
control-plane
line con 0
line aux 0
line vty 0 4
end
可以看到已经配置了上行速链路和上行速端口。
总结:
1. 配置了以太网通道后这件的路径成本变成了12
2. 一个网段必须有且只能有一个端口是指定端口
3. 根网桥(即就是根交换机)上的端口都是指定端口
4. 一个非根交换机上必须有只能有一个根端口
5. 不是根端口也不是指定端口会被阻塞。
6. PVST是每VLAN生成树
7. 设置速端口,在接入层交换机上,设置上行速链路也是
8. 参与捆绑的端口必须属于同一个VLAN,物理参数设置应该相同。

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
SELinux深入理解SELinux深入理解
1. 简介 SELinux带给Linux的主要价值是:提供了一个灵活的,可配置的MAC机制。 Security-Enhanced Linux (SELinux)
p2p linux debian 访问控制 标识符 -
深入理解this
目录1. 执行上下文(1)执行上下文概念(2)创建执行上下文2. this 指向(1)默认绑定(全局环境)(2)隐式绑定(上下
js javascript 执行上下文 全局对象 显式