1. 生成树基本概念
生成树的定义 :STP就是在具有回路的交换机网络上,生成没有回路的逻辑网络的方法。
STP有两种特殊的网桥:根桥和指定桥。网桥上的端口有不同的角色:根端口、指定端口和阻塞端口。
STP的作用是为了防止环路问题,其实环路问题如果控制好,可以形成冗余链路,起到备用线路的作用,不过一般不用,环路有很多缺陷,如:易读性差,不好控制等。
STP工作原理:
通俗易懂的讲:
STP协议通过交换机 ID 自动协商 谁为主根交换机,主根交换机跟所有网络相通,而其它交换机连接了根交换机的那个端口也必须相通,而ID小的会被优先down掉端口,从而避免环线带来的广播风暴。
STP可以通过人工干预优先级 谁为主根交换机,从而达到可控性与提高通信效率。
关于生成树协议包结构分析我写在了下面:
https://blog.csdn.net/qq_38626043/article/details/103872383
除了STP协议,现在已经有了RSTP协议(快速生成树协议)与MSTP(多生成树协议,支持vlan生成根)
RSTP:
MSTP:
2. 链路聚合
- 概念
也叫做链路汇聚或端口聚合。是将交换机上的多个端口在物理上连接起来,在逻辑上捆绑在一起,形成一个有较大带宽的端口,实现负载均衡,并提供冗余链路
- 链路聚合的工作原理 。
链路聚合是链路带宽扩展的一个重要途径,符合802.3ad标准。它可以把多个端口的带宽叠加起来.
- 聚合协议
PAgP(Port Aggregation Protocol,端口聚集协议)和LACP(Link Aggregation Control Protocol,链路聚集控制协议)都是用于自动创建链路聚合的。所不同的是,PAgP是思科专有协议,而LACP是IEEE 802.3ad定义的公开标准,这就像ISL和802.1Q一样 。无论是PAgP还是LACP,都是通过在交换机的级联接口之间互相发送数据包来协商创建链路聚合的。交换机接口收到对方的要求建立PAgP或者LACP数据后,如果允许,交换机会动态将物理端口捆绑形成聚合链路。
- 聚合条件
- 端口必须处于相同的VLAN之中或都为TRUNK口(其Allowed Vlan和Native Vlan都应该相同)
- 端口必须使用相同的网络介质
- 端口必须都处于全双工工作模式
- 端口必须是相同传输速率的端口
- 本端是手工(动态)配置,另外一端也应该是手工(动态)配置
3. 实例
配置两端IP
S0:
Switch(config)#interface range fastEthernet 0/1-2
Switch(config-if-range)#switchport mode trunk
Switch(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#channel-protocol lacp
Switch(config-if-range)#channel-group 1 mode active
Creating a port-channel interface Port-channel 1
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#
Switch(config)#port-channel load-balance dst-ip
PAgP是只有思科的设备才有,所以一般建议配置LACP。
- PAgP - 思科专利
- LACP (IEEE 802.3ad) - 国际通用标准
在交换机查看端口聚合可以使用的协议
其实如果两边都配置active 也是可以的,现在的交换机都比较智能,都能自动识别。
active Enable LACP unconditionally #主动发送LACP报文
auto Enable PAgP only if a PAgP device is detected #被动发送PAgP报文
desirable Enable PAgP unconditionally #主动发送PAgP报文
on Enable Etherchannel only #手动设置,需要两边都设置成on
passive Enable LACP only if a LACP device is detected #被动接收LACP报文
S1:
Switch(config)#interface range fastEthernet 0/1-2
Switch(config-if-range)#switchport mode trunk
Switch(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#channel-protocol lacp
Switch(config-if-range)#channel-group 1 mode passive
Creating a port-channel interface Port-channel 1
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#
Switch(config)#port-channel load-balance dst-ip