STP实验

实验环境:Packet Tracert5.0
实验设备:2960交换机三台,PC三台
实验拓扑:
STP(Spanning  Tree Protocol)生成树协议,主要用来防止二层环路,方法是阻塞一些冗余的接口(如拓扑图中橙色的接口就是被STP阻塞的)
 
1.先来说一下PortFsat
设备在连接到交换机的接口上时,会经历生成树的几个过程(侦听,学习,转发或阻塞),经历这些过程是需要一定的时间的,在这段时间内连接到接口上的设备是不能通过此接口进行通信。这样做主要是避免产生环路,但主机等终端设备连接在交换机端口是不会产生环路的,这就导致了终端连接上交换机的一定时间内是不能通信的。PortFast就是解决这个问题的,他使得指定的交换机接口不经历侦听和学习的过程,而直接到转发状态,使终端可以马上使用。
在实验中也能验证这一点,当端口设置为portfast时,连接上PC后,交换机接口马上变绿,而未设置portfast的端口,连接上PC后,会等待一个时间,此时交换机接口是橙色,过了一会才变绿。
 
2.自动选举根桥结果
switch1:
Switch#show spanning
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0001.C74E.CD71
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0001.C74E.CD71
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role     Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1              Desg   FWD 19        128.1    P2p
Fa0/2              Desg   FWD 19        128.2    P2p
Fa0/3              Desg   FWD 19        128.3    P2p
 
switch2:
Switch#show spanning
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0001.C74E.CD71
             Cost        19
             Port        2(FastEthernet0/2)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     00D0.BC60.5BAA
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1              Altn    BLK  19         128.1    P2p
Fa0/2              Root   FWD 19        128.2    P2p
Fa0/3              Desg   FWD 19        128.3    P2p
 
switch0:
Switch#show spanning
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0001.C74E.CD71
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0001.C902.7566
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1              Root   FWD 19        128.1    P2p
Fa0/2              Desg   FWD 19        128.2    P2p
Fa0/3              Desg   FWD 19        128.3    P2p
 
STP的端口状态有5种:
1.禁用
2.拥塞
3.监听
4.学习
5.转发
STP的端口角色有4种:
1.禁用端口
2.可替代端口
3.指定端口
4.根端口

从三台交换机的输出结果可以看出:
switch1为root,因为它的所有接口都是指定接口。switch2的f0/1接口被STP阻塞以防止环路。
 
STP的端口有以下规定:
1.root交换机上的所有接口都是指定接口
2.每个网段只能有一个指定接口
3.非root交换机到root的开销最小的接口为root接口
4.阻塞剩下的端口
 
根交换机的选取:优先级最小的成为根交换机,如果相同,则MAC地址最小的成为根交换机
 
自动选举的root交换机可能不是最优的,我们通常是手动指定那一台交换机作为root
可以通过spanning-tree vlan 1 root primary 将交换机设置为主根(本质也是修改优先级为某个值)
spanning-tree vlan 1 root secondary将交换机设置为从根(也就是备份)
 
还可以通过手动指定交换机的优先级来影响根交换机的选取
spanning-tree vlan 1 priority 0
 

你可能感兴趣的:(路由,实验,STP,思科)