大家好,今天我們來學習交流一下Cisco交換機生成樹協議STP的配置實例和PVST負載均衡。
感謝大家閱讀本文章。如在閱讀本文中有什麼不了解的地方盡可關注留言,我將第一時間為您解答疑惑。有大神看出了問題也請多多指教。
本次實驗目的,主要為以下兩點
1、理解 STP 的工作原理;
2、掌握 STP 樹的控制;
3、利用 PVST 進行負載均衡。
實驗參考
1、配置接口的快速生成樹-----讓接口快速響應(2-3 秒內)
Switch(config)#interface range fa0/1 – 24
Switch(Config-if-range)switchport mode Access
Switch(config-if-range)#spanning-tree portfast
2、配置 STP 幹道埠權值----允許埠權值數值低的 VLAN 通過
Switch(config)#interface fastethernet0/1
Switch(config-if)# switchport mode trunk
Switch(config-if)# spanning-tree vlan 8 port-priority 10 //將埠權值 10
賦與VLAN 8
Switch(config-if)# spanning-tree vlan 9 port-priority 10
Switch(config-if)# spanning-tree vlan 10 port-priority 10
Switch(config)#interface fastethernet0/2
Switch(config-if)# switchport mode trunk
Switch(config-if)# spanning-tree vlan 3 port-priority 10 //將埠權值 10
賦與VLAN 3
Switch(config-if)# spanning-tree vlan 4 port-priority 10
Switch(config-if)# spanning-tree vlan 5 port-priority 10
Switch(config-if)# spanning-tree vlan 6 port-priority 10
基於埠權值的負載均衡示意圖
trunk1 將發送和接收 VLAN8-10 的數據,trunk2 將發送和接收 VLAN3-6 的數據,如
圖所示:
3、配置 STP 幹道埠路徑值----允許埠路徑值開銷小的 VLAN 通過
Switch(config)#interface fastethernet0/1
Switch(config-if)# switchport mode trunk
Switch(config-if f)#switchport trunk encap dot1q //只能是 dot1q模式
Switch(config-if)# spanning-tree vlan 2 cost 20 //設置 Vlan2 生成樹路徑值為 20
Switch(config-if)# spanning-tree vlan 3 cost 30
Switch(config-if)# spanning-tree vlan 4 cost 30
Switch(config)#interface fastethernet0/2
Switch(config-if)# switchport mode trunk
Switch(config-if f)#switchport trunk encap dot1q //只能是 dot1q模式
Switch(config-if)# spanning-tree vlan 8 cost 20 //設置 Vlan2 生成樹路徑值為 20
Switch(config-if)# spanning-tree vlan 9 cost 30
Switch(config-if)# spanning-tree vlan 10 cost 30
也可以通過配置配置 STP路徑值來實現負載均衡,Trunk1 走VLAN8-10,Trunk2 走
VLAN2-4;如下圖所示:
實驗環境
1、Cisco3560 交換機 2 臺;
2、計算機 2 臺;
3、Console 電纜 1 條、直通線 2條,交叉線 2 條。
實驗拓撲
實驗內容
1、用兩根雙絞線將兩臺交換機連接起來做生成樹配置。理解埠冗餘及增加帶寬配置方法。
2、在SwitchA查看生成樹情況,用show spanning-tree brief命名輸出。
3、在SwitchB查看生成樹情況,用show spanning-tree brief命名輸出。
驗證測試:在SwitchA上的Fa0/24埠處於BLK狀態,分析原因?
4、修改SwitchA的BID優先級,讓SwitchA成為Root Bridge。設置交換機SwitchAr
優先級為4096,數值最小的交換機為根交換機(也稱根橋)交換機SwitchBr優先
級採用默認優先級(32768),因此SwitchA將成為根交換機。
SwitchA(config)#spanning-tree vlan 1 priority 4096
5、在SwitchA上查看show spanning-tree 命名輸出結果。
6、在SwitchB上查看show spanning-tree 命名輸出結果。
驗證測試:在SwitchB上的Fa0/23埠處於BLK狀態,分析原因?
7、如果將SwitchB的Fa0/23和Fa0/24的狀態調換過來,可能通過修改什麼參數來實現?可以在SwitchA降低接口優先級來實現。
SwitchA(config)#int fa0/24
SwitchA(config-if)#spanning-tree vlan 1 port-priority 112
8、修改後,在SwitchA查看show spanning-tree 命名輸出結果。
9、SwitchB上出現了如下反應(Fa0/23和Fa0/24)接口狀態被調換。
提問: 通過修改什麼參數可以將SwitchB的F0/23和Fa0/24接口恢復為原來的狀態。可以在SwitchB上降低fa0/24接口的開銷。
SwitchB(config)#int fa0/24
SwitchB(config-if)#spanning-tree vlan 1 cost 18
10、修改後,在SwitchB查看show spanning-tree 命名輸出結果。
11、驗證網絡拓撲變化時,ping的丟包情況。
實驗常見問題
交換機的默認優先級都是32 768,而MAC較低的成為了根橋。
以上為本文全部內容,如有學習需要可使用Cisco Packet Tracer進行模擬實驗。有問題也可留言提問。感謝大家的觀看,謝謝支持。如果大家對網絡技術有興趣,歡迎大家關注。
轉載請註明