这里将不再过度阐述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]q
MSTP
[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]q
MSTP
[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的配置。