当网络有多个VLAN时,PVST技术会为每一个VLAN构建一棵生成树,来控制多个VLAN转发数据流量的负载平衡,默认情况下思科的交换机是开启了PVST技术。
假设这是一个部署了PVST技术的局域网络,这个网络需要转发不同VLAN(VLAN10和VLAN20)的数据流量,PVST技术会为VLAN10和VLAN20设置不同的主备链路。在上图中,左边的链路既是VLAN20的主链路,同时还是VLAN10的备用链路;右边的链路既是VLAN10的主链路,同时还是VLAN20的备用链路。
也就是说,PVST技术会为VLAN10和VLAN20设置不同的主备转发链路(红色表示VLAN10,蓝色表示VLAN20),以VLAN10为例,VLAN10的数据流量默认情况下是转发到主链路的,但是当VLAN10的主链路发生故障时,就会切换到VLAN10的备用链路上转发数据,此时VLAN10和VLAN20的数据流量都是转发到同一链路的。
对于VLAN20也是同样的道理。
R1交换机开启PVST技术,配置如下:
R1(config)#spanning-tree vlan 10 root secondary
VLAN 10 bridge priority set to 16384
VLAN 10 bridge max aging time unchanged at 20
VLAN 10 bridge hello time unchanged at 2
VLAN 10 bridge forward delay unchanged at 15
R1(config)#spanning-tree vlan 20 root primary
VLAN 20 bridge priority set to 8192
VLAN 20 bridge max aging time unchanged at 20
VLAN 20 bridge hello time unchanged at 2
VLAN 20 bridge forward delay unchanged at 15
R1(config)#
设置为VLAN10的备用链路,同时设置为VLAN20的主链路。
R2交换机开启PVST技术,配置如下:
R2(config)#spanning-tree vlan 10 root primary
VLAN 10 bridge priority set to 8192
VLAN 10 bridge max aging time unchanged at 20
VLAN 10 bridge hello time unchanged at 2
VLAN 10 bridge forward delay unchanged at 15
R2(config)#spanning-tree vlan 20 root secondary
VLAN 20 bridge priority set to 16384
VLAN 20 bridge max aging time unchanged at 20
VLAN 20 bridge hello time unchanged at 2
VLAN 20 bridge forward delay unchanged at 15
设置为VLAN10的主链路,同时设置为VLAN20的备用链路。
然后show命令查看R3设备VLAN10的STP信息,配置如下:
R3#show spanning-tree vlan 10 brief
VLAN10
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address cc02.30ac.0001
Cost 19
Port 2 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc03.14b4.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/0 128.1 128 19 BLK 19 16384 cc01.2a54.0001 128.2
FastEthernet0/1 128.2 128 19 FWD 0 8192 cc02.30ac.0001 128.2
R3#
由于我们通过PVST技术设置了R3设备的f0/0端口所在链路是VLAN10的备用链路,因此R3设备的f0/0口默认是Blocking(BLK)状态。
然后show命令查看R3设备VLAN20的STP信息,配置如下:
R3#show spanning-tree vlan 20 brief
VLAN20
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address cc01.2a54.0002
Cost 19
Port 1 (FastEthernet0/0)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc03.14b4.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/0 128.1 128 19 FWD 0 8192 cc01.2a54.0002 128.2
FastEthernet0/1 128.2 128 19 BLK 19 16384 cc02.30ac.0002 128.2
R3#
同样的道理,R3设备的f0/1端口所在链路是VLAN20的备用链路,因此该端口默认情况下是Blocking(BLK)状态。
到此,PVST部署实验完成。