![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F9ac987f2-8948-4a4e-943f-a9bcbd6bfd82%2FUntitled.png?table=block&id=ddcec1ea-7e59-4d83-98f4-b824bec55063&cache=v2)
链路聚合:
链路聚合 (Link Aggregation),也称为端口捆绑、端口聚集或链路聚集,链路聚合是将多个端口聚合在一起形成1个汇聚组,以实现出/入负荷在各成员端口中的分担。从外面看起来,1个汇聚组好像就是1个端口。
优点:
提高链路带宽
提高可靠性:同组成员彼此动态备份
要求:
加入链路聚合的端口的带宽,速度,vlan等设置都要一样
链路聚合 | 手工模式 | LACP | PAGP |
名称 | ㅤ | 链路聚合控制协议(IEEE802.3ad) | 端口聚合协议 |
开放性 | ㅤ | 开放标准 | 思科私有 |
标准 | ㅤ | Etherchannel and IEEE 802.3ad | Etherchannel |
模式 | Static On Mode | Active/Passive | Auto/Desirable |
SW1和SW2的f0/20-f0/23作为链路聚合的端口,PC1和PC2作为vlan1互相通信:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FNoFb9XLlYGTP2fv.png?table=block&id=35573177-03b0-49fc-854a-377da850b28c&cache=v2)
SW1:
Switch(config)#int range f 0/20-23 #设置f0/20-23端口四个端口设置LACP Switch(config-if-range)#channel-protocol lacp #设置链路聚合控制协议为LACP(默认值),LACP为标准协议,pagp为思科私有 Switch(config-if-range)#switchport trunk encapsulation dot1q #设置帧格式为dot1q,Pt模拟器只有在三层交换机支持,二层教交换机不支持 Switch(config-if-range)#switchport mode trunk #设置为trunk模式 Switch(config-if-range)#channel-group 1 mode active #设置指定端口组为1,信道ID为1,模式为active模式,两边只要至少一边时active模式即可 Switch(config-if)#int port-channel 1 #创建捆绑接口,就是用channel-group 1加入的相同ID的物理接口,捆绑成一个逻辑接口 Switch(config-if)#switchport trunk encapsulation dot1q #PT模拟器二层交换机不支持,可以不用设置 Switch(config-if)#switchport mode trunk #设置捆绑接口为trunk模式 Switch(config-if)#switchport trunk allowed vlan all #trunk默认允许所有vlan通过 Switch(config)#show interfaces port-channel 1 #查看捆绑端口的信息,三层交换机可以查看
SW2也是同样的配置:
SW1:
Switch(config)#int range f 0/20-23 Switch(config-if-range)#switchport trunk encapsulation dot1q Switch(config-if-range)#switchport mode trunk Switch(config-if-range)#channel-group 1 mode active Switch(config-if)#int port-channel 1 #创建捆绑接口,就是用channel-group 1加入的相同ID的物理接口,捆绑成一个逻辑接口 Switch(config-if)#switchport trunk encapsulation dot1q #PT模拟器二层交换机不支持,可以不用设置 Switch(config-if)#switchport mode trunk #设置捆绑接口为trunk模式 Switch(config-if)#switchport trunk allowed vlan all #trunk默认允许所有vlan通过
查看端口通道信息:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FXmg7BGSby5a8kiK.png?table=block&id=be05b89b-8439-4202-b495-7b4b5859c991&cache=v2)
Switch#show etherchannel port-channel Channel-group listing: ---------------------- Group: 1 ---------- Port-channels in the group: --------------------------- Port-channel: Po1 (Primary Aggregator) ------------ Age of the Port-channel = 00d:04h:03m:59s Logical slot/port = 2/1 Number of ports = 4 GC = 0x00000000 HotStandBy port = null Port state = Port-channel Protocol = LACP Port Security = Disabled Ports in the Port-channel: Index Load Port EC state No of bits ------+------+------+------------------+----------- 0 00 Fa0/23 Active 0 0 00 Fa0/20 Active 0 0 00 Fa0/21 Active 0 0 00 Fa0/22 Active 0 Time since last port bundled: 00d:04h:02m:35s Fa0/22 Switch# Switch#
查看聚合链路状态:
Switch#show etherchannel summary Flags: D - down P - in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use f - failed to allocate aggregator u - unsuitable for bundling w - waiting to be aggregated d - default port Number of channel-groups in use: 1 Number of aggregators: 1 Group Port-channel Protocol Ports ------+-------------+-----------+---------------------------------------------- 1 Po1(SU) LACP Fa0/20(P) Fa0/21(P) Fa0/22(P) Fa0/23(P)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FrPOC1GVxjQfHYkU.png?table=block&id=1e1ef88f-2515-435e-9560-feab819684f5&cache=v2)
两个PC互PING:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FEQpMlAr8SvJf9Ck.png?table=block&id=f030903b-a0da-4cbc-972d-4ebc0687b7ce&cache=v2)
链路状态:
交换机之间的线路被捆绑成一个逻辑链路,不会被STP阻断,所有的链路都是开启状态。
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FyYHKuhNf3Odvt6z.png?table=block&id=4c915026-b48b-4199-a5bd-69c39f8e07a6&cache=v2)
手工模式:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs2.loli.net%2F2022%2F05%2F08%2FDRgydN5rcZaPYfh.png?table=block&id=6f6c94a2-e4e6-4954-a810-1f8c4ee0e67e&cache=v2)
设置如图上所示
手工模式设置链路聚合,在设置好端口聚合之前要先把端口关闭,设置好之后再打开端口:
Switch(config)#int range f0/3-4 Switch(config-if-range)#shutdown Switch(config-if-range)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down %LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down Switch(config-if-range)#channel-group 1 mode on Switch(config-if-range)# Creating a port-channel interface Port-channel 1 Switch(config-if-range)#no shutdown Switch(config-if-range)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up %LINK-5-CHANGED: Interface Port-channel1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up %LINK-5-CHANGED: Interface FastEthernet0/2, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
sw1:
查看链路信息:
Switch#show etherchannel summary Flags: D - down P - in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use f - failed to allocate aggregator u - unsuitable for bundling w - waiting to be aggregated d - default port Number of channel-groups in use: 1 Number of aggregators: 1 Group Port-channel Protocol Ports ------+-------------+-----------+---------------------------------------------- 1 Po1(SU) - Fa0/1(P) Fa0/2(P) p代表加入链路汇聚成功,H代表热备份,lacp最多支持8+8备份模式
查看汇聚端口:
Switch#show etherchannel port-channel 1 Channel-group listing: ---------------------- Group: 1 ---------- Port-channels in the group: --------------------------- Port-channel: Po1 ------------ Age of the Port-channel = 00d:00h:05m:01s Logical slot/port = 2/1 Number of ports = 2 GC = 0x00000000 HotStandBy port = null Port state = Port-channel Protocol = PAGP Port Security = Disabled Ports in the Port-channel: Index Load Port EC state No of bits ------+------+------+------------------+----------- 0 00 Fa0/1 On 0 0 00 Fa0/2 On 0 Time since last port bundled: 00d:00h:03m:40s Fa0/2 Switch#
PAGP:
配置都一样,channel-protocol pagp #设置协议为PAGP协议 只要有一边设置成channel-group 1 mode Desirable,就可以组成聚合链路