PVST+的配置

PVST+的配置

问题

二层网络中有可能出现因为线路故障而导致的通信故障,通过冗余线路可以消除因为某一线路故障而导致的网络中断。
但是因为冗余线路的存在,又可能会出现广播风暴、相同帧的不断复制和MAC地址表不稳定。
1)配置Switch1为vlan1的主根,Switch2为vlan1的次根

方案

为了保证在冗余环境下不会出广播风暴等问题,引入了生成树(STP)协议。通过生成树协议可以把冗余线路上的某一个端口置为阻塞(BLOCKING)状态,防止广播风暴的产生,当某一线路出现故障时,被阻塞的端口自动进入转发(FORWARDING)状态,保证网络的畅通性。
网络拓扑如图所示:
在这里插入图片描述

步骤

实现此案例需要按照如下步骤进行。

步骤一:将三台交换机相连的端口配置为中继端口

tarena-sw1(config)#interface range f0/12 -13
tarena-sw1(config-if-range)#switchport mode trunk
tarena-sw2(config)#interface range f0/12, f0/23
tarena-sw2(config-if-range)#switchport mode trunk
tarena-sw3(config)#interface range f0/13 ,f0/23
tarena-sw3(config-if-range)#switchport mode trunk

步骤二:设置tarena-sw1为根网桥

根网桥唯一的依据是BID最小。BID分为两个部分:优先级+MAC地址。比较BID时,先比较优先级,如果优先级相同才比较MAC地址。
优先级取值范围是0到65535,默认值为32768。在查看优先级时,即使是默认值看到的也不是32768,因为交换机的优先级采用系统优先级+VLAN编号的方式,所以查看到的VLAN1默认优先级是32769(系统优先级32768+VLAN编号1)。

tarena-sw1(config)#spanning-tree vlan 1 root primary 
tarena-sw1(config)#exit
tarena-sw1#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID   Priority    24577   //默认优先级为32768
             Address     0060.478B.607B
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    24577  (priority 24576 sys-id-ext 1)
             Address     0060.478B.607B
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts   Cost      Prio.Nbr   Type
-----------    ------  --- --------   --------  ----------------------
Fa0/13           Desg    FWD    19        128.13     P2p
Fa0/12           Desg    FWD    19        128.12     P2p

查看到的结果,Root ID部分指的是根网桥信息,Bridge ID部分是当前所操作的交换机信息,如果二者一致表示当前操作的交换机就是根网桥。

步骤三:设置tarena-sw2为次根,即BID值大小居中

tarena-sw2(config)#spanning-tree vlan 1 root secondary
tarena-sw2#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577  //此处虽然与tarena-sw1一样,但MAC地址更大
             Address     0060.478B.607B
             Cost        19
             Port        12(FastEthernet0/12)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    28673  (priority 28672 sys-id-ext 1)
             Address     0090.0C77.8924
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role Sts    Cost      Prio.Nbr    Type
----------      ---- ----   -----      -------- ---------
Fa0/12           Root FWD      19        128.12     P2p
Fa0/23           Desg FWD      19        128.23     P2p

步骤四:tarena-sw3不需要做改动,直接查看STP状态

tarena-sw3#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     0060.478B.607B
             Cost        19
             Port        13(FastEthernet0/13)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0060.5C9E.2E75
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts     Cost      Prio.Nbr     Type
----------      ------ ----   ----- --------        ----------
Fa0/13           Root    FWD      19        128.13       P2p
Fa0/23           Altn    BLK      19        128.23       P2p

观察Sts列(即状态status),Fa0/23端口当前是耳塞(BLK)状态,即该端口不能转发数据。

步骤五:模拟交换机间线缆故障。将tarena-sw2的Fa0/12口shutdown,再次检查tarena-sw3端口状态

tarena-sw2(config)#interface f0/12
tarena-sw2(config-if)#shutdown
tarena-sw3#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     0060.478B.607B
             Cost        19
             Port        13(FastEthernet0/13)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0060.5C9E.2E75
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20
Interface        Role   Sts     Cost      Prio.Nbr     Type
----------      ------ ----   ----- --------        ----------
Fa0/13           Root    FWD      19        128.13       P2p
Fa0/23           Desg    FWD      19        128.23       P2p

从tarena-sw3的输出可以看到,Fa0/23端口已从阻塞状态切换到转发(FWD)状态,保证了网络的畅通。当线路恢复(在rarena-sw2的Fa0/12端口执行no shutdown)后,tarena-sw3的Fa0/23端口将重新进入阻塞状态以网止环路的产生。
在查看时,tarena-sw3的Fa0/23端口不是立即进入转发或是阻塞状态。生成树端口有阻塞,侦听,学习和转发四个状态,当拓扑变化时,端口状态改变要遵从这些状态的逐渐改变。

猜你喜欢

转载自blog.csdn.net/qq_43237999/article/details/89738851