Ủng hộ chủ thớt bài lab STP 802.1D nè:
Lab Topo:

Yêu cầu:
  • Tạo VLAN 10, 20, 30 trên cả 3 switch SW1, SW2 & SW3
  • Cấu hình PVST sao cho:
    • Đối với VLAN 10:
      • SW1 là root switch
      • Port F0/2 trên SW3 & port F0/2 trên SW2 là root port
    • Đối với VLAN 20:
      • SW2 là root switch
      • Port F0/2 trên SW1 là Designated Port, Port F0/1 trên SW3 là Non-Designated Port.
    • Đối với VLAN 30:
      • SW3 là root switch

Sử dụng lệnh show spanning-tree vlan 1 để xác định BID của các switch như sau:
  • SW1: Priority 32769 , Address 0014.1c2c.3e80
  • SW2: Priority 32769, Address 0009.e8fb.b980
  • SW3: Priority 32769, Address 0014.1c2c.cd00
Tạo VLAN 10, 20, 30 trên SW1, SW2, SW3 như sau:
SW1(config)#vlan 10,20,30

Trước khi cấu hình STP, kiểm tra đảm bảo các kết nối giữa các switch UP và được cấu hình trunk cho phép VLAN10, 20, 30 đi qua.

Cấu hình STP mode PVST trên tất cả các switch:
SW1(config)#spanning-tree mode pvst

Cấu hình đối với VLAN 10:
So sánh các BID mặc định của các switch, bạn dễ dàng nhận thấy SW2 sẽ là root switch cho cả 3 vlan 10,20 & 30. Để SW1 là root switch của vlan 10, bạn phải thay đổi BID của SW1 thành nhỏ nhất bằng cách cấu hình spanning-tree vlan 10 root primary hoặc giảm BID Priority xuống. Lưu ý bước nhảy của BID Priority là 4096. Cấu hình như sau:
SW1(config)#spanning-tree vlan 10 priority 28672

Kiểm tra:
SW1(config)#do sho span vl 10

VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 28682
Address 0014.1c2c.3e80
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 28682 (priority 28672 sys-id-ext 10)
Address 0014.1c2c.3e80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p

SW2#sho span vl 10

VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 28682
Address 0014.1c2c.3e80
Cost 19
Port 2 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0009.e8fb.b980
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Port ID Designated Port ID
Name Prio.Nbr Cost Sts Cost Bridge ID Prio.Nbr
---------------- -------- --------- --- --------- -------------------- --------
Fa0/1 128.1 19 FWD 19 32778 0009.e8fb.b980 128.1
Fa0/2 128.2 19 FWD 0 28682 0014.1c2c.3e80 128.1

SW3(config-if)#do sho span vl 10

VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 28682
Address 0014.1c2c.3e80
Cost 19
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0014.1c2c.cd00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p

Hiện nay Port F0/2 trên SW3 đang là Non-Designated Port. Để Port F0/2 trên SW3 là Root Port bạn có 2 cách:
1. Giảm cost của F0/2 của SW2 & F0/2 SW3 xuống sao cho tổng cost của 2 port này < 38
2. Tăng cost của F0/1 SW3 lên >38.
SW3(config)# interface FastEthernet0/1
SW3(config-if)# spanning-tree vlan 10 cost 39

Kiểm tra:
SW3(config-if)#do sho span vl 10

VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 28682
Address 0014.1c2c.3e80
Cost 38
Port 2 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0014.1c2c.cd00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Altn BLK 39 128.1 P2p
Fa0/2 Root FWD 19 128.2 P2p

Cấu hình đối với VLAN 20:
Mặc định SW2 có BID thấp nhất do vậy bạn không cần thay đổi BID. Kiểm tra cấu hình cho thấy:
SW2#sho span vl 20

VLAN0020
Spanning tree enabled protocol ieee
Root ID Priority 32788
Address 0009.e8fb.b980
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32788 (priority 32768 sys-id-ext 20)
Address 0009.e8fb.b980
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Port ID Designated Port ID
Name Prio.Nbr Cost Sts Cost Bridge ID Prio.Nbr
---------------- -------- --------- --- --------- -------------------- --------
Fa0/1 128.1 19 FWD 0 32788 0009.e8fb.b980 128.1
Fa0/2 128.2 19 FWD 0 32788 0009.e8fb.b980 128.2

SW1#sho span vl 20

VLAN0020
Spanning tree enabled protocol ieee
Root ID Priority 32788
Address 0009.e8fb.b980
Cost 19
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32788 (priority 32768 sys-id-ext 20)
Address 0014.1c2c.3e80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p


SW3(config-if)#do sho span vl 20

VLAN0020
Spanning tree enabled protocol ieee
Root ID Priority 32788
Address 0009.e8fb.b980
Cost 19
Port 2 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32788 (priority 32768 sys-id-ext 20)
Address 0014.1c2c.cd00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Altn BLK 19 128.1 P2p
Fa0/2 Root FWD 19 128.2 P2p

Hiện nay Port F0/1 trên SW3 đang là Non-Designated Port. Do BPDU cost gửi ra cổng F0/1 SW3 & F0/2 SW1 có cost bẳng nhau (19). Do vậy để bầu chọn Designated Port trên segment giữa SW1 & SW3, port trên switch có BID nhỏ hơn sẽ là Designated Port. Trong trường hợp này SW1 BID < SW3 BID, do vậy F0/2 SW1 là DP. Để thay đổi F0/1 SW1 thành DP, bạn cần tăng BID SW1 < BID SW3. Cấu hình như sau:
SW1(config)#span vl 20 priority 36864
Kiểm tra:
SW1(config)#do sho span vl 20

VLAN0020
Spanning tree enabled protocol ieee
Root ID Priority 24596
Address 0009.e8fb.b980
Cost 21
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 36884 (priority 36864 sys-id-ext 20)
Address 0014.1c2c.3e80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 21 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p
SW3#sho span vl 20

VLAN0020
Spanning tree enabled protocol ieee
Root ID Priority 24596
Address 0009.e8fb.b980
Cost 19
Port 2 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32788 (priority 32768 sys-id-ext 20)
Address 0014.1c2c.cd00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300

Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Root FWD 19 128.2 P2p

Cấu hình đối với VLAN 30:
SW3(config)#spanning-tree vlan 30 root primary

SW3(config)#do sho span vl 30