這里將不再過度闡述STP和鏈路聚合的理論知識,不清楚的同學可以去觀看Cisco文章中的理論知識?
理論知識https://blog.csdn.net/2301_76341691/article/details/145166547?fromshare=blogdetail&sharetype=blogdetail&sharerId=145166547&sharerefer=PC&sharesource=2301_76341691&sharefrom=from_linkhttps://blog.csdn.net/2301_76341691/article/details/145166547?fromshare=blogdetail&sharetype=blogdetail&sharerId=145166547&sharerefer=PC&sharesource=2301_76341691&sharefrom=from_link
目錄
一、STP(生成樹協議)
二、RSTP(快速生成樹)
三、鏈路聚合(Link Aggregation)
作用:
配置方式:
四、Eth-Trunk技術原理
五、任務
六、拓撲圖
七、代碼
八、注意事項:
一、STP(生成樹協議)
STP是一種網絡協議,用于在交換網絡中防止冗余鏈路形成環路,從而避免網絡廣播風暴和重復拷貝幀等問題。它通過構建一棵自然樹來阻塞冗余鏈路,同時實現鏈路備份和鏈路最優化。STP的通信是通過橋協議數據單元(BPDU)進行的,支持STP的交換機之間通過BPDU報文交換信息。
STP的主要概念包括:
- 根橋(Root Bridge):在STP網絡中,每個交換機都會選舉出一個根橋,通常是ID號最小的交換機。
- 根端口(Root Port):非根交換機上連接到根橋的端口被選舉為根端口。
- 指定端口(Designated Port):非根交換機上連接到非根橋的端口被選舉為指定端口。
二、RSTP(快速生成樹)
RSTP是STP的改進版本,它減少了網絡收斂時間,提高了網絡的響應速度。RSTP在檢測到鏈路故障時能夠更快地調整網絡拓撲,從而減少故障的影響。
三、鏈路聚合(Link Aggregation)
鏈路聚合是一種將多個物理鏈路捆綁成一個邏輯鏈路的技術,以提高網絡的帶寬和可靠性。以下是鏈路聚合的一些關鍵點:
作用:
- 增加帶寬:通過將多個物理鏈路加入一個邏輯鏈路,實現鏈路的冗余。
- 提高可靠性:如果一個物理鏈路出現故障,其他鏈路可以接管流量,保證網絡的連續性。
配置方式:
- 手工聚合:手動將物理接口加入到一個聚合組中,所有物理接口都處于UP狀態,可以轉發數據。這種方式簡單,但需要確保接口的配置相同。
- LACP(Link Aggregation Control Protocol):一種基于協議的聚合方式,通過報文協商成員鏈路,可以設置最大活動鏈路數量,選擇主設備等。
四、Eth-Trunk技術原理
Eth-Trunk技術允許將多個物理接口捆綁成一個邏輯接口,這樣既不用替換接口板也不會浪費IP地址資源。這種技術特別適用于網絡中需要高帶寬和冗余設計的場合。
五、任務
交換機A和交換機B之間配置以太通道,交換機A配置為VLAN10和VLAN20的根交換機,VLAN30和vlan40的備份根交換機,交換機B配置為VLAN30和VLAN40的根交換機,VLAN10和VLAN20的備份根交換機
六、拓撲圖
七、代碼
?在SWA上的配置:
<Huawei>sys
[Huawei]sysname SWA
[SWA]int Eth-Trunk 1 //創建一個聚合端口1
[SWA-Eth-Trunk1]bpdu enable
[SWA-Eth-Trunk1]mode lacp-static //模式為靜態lacp
[SWA-Eth-Trunk1]q
[SWA]int g0/0/1
[SWA-GigabitEthernet0/0/1]eth-trunk 1 //將g0/0/1加入聚合端口
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA-GigabitEthernet0/0/1]q
[SWA]int g0/0/2
[SWA-GigabitEthernet0/0/2]eth-trunk 1 //將g0/0/2加入聚合端口
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA-GigabitEthernet0/0/2]qMSTP[SWA]stp region-configuration
[SWA-mst-region]region-name admin
[SWA-mst-region]instance 1 vlan 10
[SWA-mst-region]instance 2 vlan 20
[SWA-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA-mst-region]q
[SWA]stp instance 1 root primary
[SWA]stp instance 2 root secondary
[SWA]stp pathcost-standard legacy
Warning: The path cost of the current process will be set to the default value b
ecause the path cost standard is changed.
[SWA]stp edged-port
[SWA]stp enable
[SWA]int g0/0/3
[SWA-GigabitEthernet0/0/3]stp root-protection
[SWA-GigabitEthernet0/0/3]q[SWA]int g0/0/3
[SWA-GigabitEthernet0/0/3]port link-type trunk
[SWA-port-group-link-type]port trunk all vlan all
[SWA-port-group-link-type]q
在SWB上的配置:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWB
[SWB]int Eth-Trunk 1
[SWB-Eth-Trunk1]bpdu enable
[SWB-Eth-Trunk1]mode lacp-static
[SWB-Eth-Trunk1]q
[SWB]int g0/0/1
[SWB-GigabitEthernet0/0/1]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB-GigabitEthernet0/0/1]q
[SWB]int g0/0/2
[SWB-GigabitEthernet0/0/2]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB-GigabitEthernet0/0/2]qMSTP[SWB]stp region-configuration
[SWB-mst-region]region-name admin
[SWB-mst-region]instance 1 vlan 10
[SWB-mst-region]instance 2 vlan 20
[SWB-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB-mst-region]q
[SWB]stp instance 1 root secondary
[SWB]stp instance 2 root primary
[SWB]stp pathcost-standard legacy
Warning: The path cost of the current process will be set to the default value b
ecause the path cost standard is changed.
[SWB]stp enable
[SWB]int g0/0/3
[SWB-GigabitEthernet0/0/3]stp root-protection
[SWB-GigabitEthernet0/0/3]q[SWB]int g0/0/3
[SWB-GigabitEthernet0/0/3]port link-type trunk
[SWB-GigabitEthernet0/0/3]port trunk all vlan all
[SWB-GigabitEthernet0/0/3]q
在SWC上的配置:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWC
[SWC]stp region-configuration
[SWC-mst-region]region-name admin
[SWC-mst-region]instance 1 vlan 10
[SWC-mst-region]instance 2 vlan 20
[SWC-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWC-mst-region]q
[SWC]stp pathcost-standard legacy
Warning: The path cost of the current process will be set to the default value b
ecause the path cost standard is changed.
[SWC]int g0/0/1
[SWC-GigabitEthernet0/0/1]stp instance 2 cost 20000
[SWC-GigabitEthernet0/0/1]q
[SWC]int g0/0/2
[SWC-GigabitEthernet0/0/2]stp instance 1 cost 20000
[SWC-GigabitEthernet0/0/2]q
[SWC]stp enable
[SWC]int g0/0/3
[SWC-GigabitEthernet0/0/3]stp disable
[SWC-GigabitEthernet0/0/3]q
[SWC]int g0/0/4
[SWC-GigabitEthernet0/0/4]stp disable
[SWC-GigabitEthernet0/0/4]q[SWC]vlan ba 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWC]int g0/0/3
[SWC-GigabitEthernet0/0/3]port link-type access
[SWC-GigabitEthernet0/0/3]port default vlan 10
[SWC-GigabitEthernet0/0/3]q
[SWC]int g0/0/4
[SWC-GigabitEthernet0/0/4]port link-type access
[SWC-GigabitEthernet0/0/4]port default vlan 20
[SWC-GigabitEthernet0/0/4]q
八、注意事項:
- 鏈路聚合可以應用于二層和三層接口,但需要注意避免形成環路。
- 在配置鏈路聚合時,需要考慮端口類型(如Access、Trunk、Hybrid)和VLAN的配置。