Cisco链路聚合(Link Aggregation)是一种将多个物理以太网链路捆绑成一个逻辑链路的技术,能够增加带宽、提供冗余备份并提高网络可靠性,在Cisco设备上,配置链路聚合通常通过EtherChannel技术实现,支持静态配置和动态协议(如PAgP、LACP),以下是详细的配置命令和步骤说明。

基本配置步骤
-
进入接口配置模式
首先需要进入需要聚合的物理接口配置模式,configure terminal interface GigabitEthernet0/1
-
将接口加入EtherChannel
使用channel-group命令将接口分配到指定的通道组,组号范围为1-256,例如创建通道组1:channel-group 1 mode ?
此处可选择模式:
- on:静态模式,不协商(需两端手动配置一致)。
- active:LACP主动模式(推荐,主动发起协商)。
- passive:LACP被动模式(等待对端发起协商)。
- desirable:PAgP主动模式(Cisco私有协议)。
- auto:PAgP被动模式。
示例(LACP主动模式):
(图片来源网络,侵删)channel-group 1 mode active
-
配置聚合接口参数
创建逻辑接口后,进入接口配置模式设置IP地址、速率等参数:interface Port-channel1 ip address 192.168.1.1 255.255.255.0 no shutdown
-
验证配置
使用以下命令检查状态:show etherchannel summary show interfaces port-channel1
高级配置选项
-
负载均衡方式:
EtherChannel支持多种负载均衡策略,可通过port-channel load-balance命令设置,例如基于源IP(src-ip)、目标IP(dst-ip)或MAC地址等。port-channel load-balance src-dst-ip
-
链路冗余与故障切换:
默认情况下,所有链路均参与负载均衡,若需设置主备链路,可在接口下添加spanning-tree portfast(避免STP阻塞)或使用lacp max-bundle限制活动链路数量。
(图片来源网络,侵删) -
配置示例(两台交换机)
交换机A:interface range GigabitEthernet0/1-2 channel-group 1 mode active interface Port-channel1 ip address 10.0.0.1 255.255.255.0
交换机B:
interface range GigabitEthernet0/1-2 channel-group 1 mode active interface Port-channel1 ip address 10.0.0.2 255.255.255.0
常见问题与注意事项
- 模式不匹配:两端必须协商一致(如均为active或均为desirable),否则链路无法聚合。
- MTU与VLAN一致性:所有物理接口的MTU、VLAN配置需完全相同。
- 接口状态:确保接口为
up状态且未被其他协议(如STP)阻塞。
相关问答FAQs
Q1:如何删除已配置的EtherChannel?
A1:进入全局配置模式,使用no interface Port-channel1删除逻辑接口,然后逐个进入物理接口执行no channel-group 1命令移除通道组配置,最后可通过no port-channel load-balance清除负载均衡策略。
Q2:LACP与PAgP的主要区别是什么?
A2:LACP(Link Aggregation Control Protocol)是IEEE标准协议,支持跨厂商设备互通;PAgP(Port Aggregation Protocol)是Cisco私有协议,仅能在Cisco设备间使用,LACP提供更灵活的协商机制(如active/passive模式),而PAgP仅支持desirable/auto模式,推荐多厂商环境使用LACP。
