链路聚合(静态LACP模式)
实验拓扑图
实验需求
1. 在交换机上创建相关VLAN;将连接PC的接口配置为Access类型并添加到相应的VLAN; 2. 将SW1、SW2之间的互联链路捆绑为Eth-Trunk,使用静态LACP模式,SW1为主动端,在该聚合链路中,两条链路为活动链路,其余一条做备份; 3. 完成配置后同一个VLAN内的PC能够互相通信。
基本配置
LSW1: vlan 10 #创建vlan 10 int vl 10 #打开vlan 10并写入vlan数据表中 ip add 192.168.10.254 24 #配置vlanIP地址 undo shutdown #开启vlan vlan 20 #创建vlan 20 int vl 20 #打开vlan 20并写入vlan数据表中 ip add 192.168.20.254 24 #配置vlanIP地址 undo shutdown #开启vlan int eth0/0/1 进入接口eth0/0/1 port link-type access #将接口转换成access接口,允许单个vlan通过 port default vlan 10 #将接口划分到vlan 10中 undo shutdown #开启接口 int eth0/0/2 进入接口eth0/0/2 port link-type access #将接口转换成access接口,允许单个vlan通过 port default vlan 20 #将接口划分到vlan 20中 undo shutdown #开启接口 LSW2: vlan 10 #创建vlan 10 int vl 10 #打开vlan 10并写入vlan数据表中 ip add 192.168.10.254 24 #配置vlanIP地址 undo shutdown #开启vlan vlan 20 #创建vlan 20 int vl 20 #打开vlan 20并写入vlan数据表中 ip add 192.168.20.254 24 #配置vlanIP地址 undo shutdown #开启vlan int eth0/0/1 进入接口eth0/0/1 port link-type access #将接口转换成access接口,允许单个vlan通过 port default vlan 20 #将接口划分到vlan 20中 undo shutdown #开启接口 int eth0/0/2 进入接口eth0/0/2 port link-type access #将接口转换成access接口,允许单个vlan通过 port default vlan 10 #将接口划分到vlan 10中 undo shutdown #开启接口
实验配置
LSW1: lacp priority 1 #将LSW1的设备LACP优先级设置为1,使其成为eth-trunk链路协商时成为主动端,LSW2的设备LACP优先级保持缺省32768,该值为越小越优先,因此LSW1的优先级比LSW2小,所以LSW1为主,LSW2为备 int eth-trunk 1 #创建聚合组1 mode lacp-static #链路聚合组模式设置为静态LACP max active-linknumber 2 #最大活跃链路数量设置为2 quit #退出链路聚合组模式 int eth0/0/3 #进入接口eth0/0/3中 eth-trunk 1 #将接口加入到聚合组1中 int eth0/0/4 #进入接口eth0/0/4中 eth-trunk 1 #将接口加入到聚合组1中 int eth0/0/5 #进入接口eth0/0/5中 eth-trunk 1 #将接口加入到聚合组1中 由于eth-trunk1聚合链路需要承载多VLAN流量,因此需要配置trunk,注意一旦聚合链路配置完成后,我们针对该聚合链路的相关配置就在int eth-trunk中也就是产生的聚合端口中完成,而不是eth0/0/3、eth0/0/4、eth0/0/5的配置模式中进行 int eth-trunk 1 #进入链路聚合组1中 port link-type trunk #设置该接口模式为trunk port trunk allow-pass vlan 10 20 #允许vlan 10和vlan 20通信 quit #退出当前配置模式 LSW2: int eth-trunk 1 #创建聚合组1 mode lacp-static #链路聚合组模式设置为静态LACP quit #退出链路聚合组模式 int eth0/0/3 #进入接口eth0/0/3中 eth-trunk 1 #将接口加入到聚合组1中 int eth0/0/4 #进入接口eth0/0/4中 eth-trunk 1 #将接口加入到聚合组1中 int eth0/0/5 #进入接口eth0/0/5中 eth-trunk 1 #将接口加入到聚合组1中 int eth-trunk 1 #进入链路聚合组1中 port link-type trunk #设置该接口模式为trunk port trunk allow-pass vlan 10 20 #允许vlan 10和vlan 20通信 quit #退出当前配置模式
理解实验
Eth-trunk的静态LACP工作方式也称为M∶N模式。这种方式同时可以实现链路负载分担和链路冗余备份的双重功能。在链路聚合组中M条链路处于活动状态,这些链路负责转发数据并进行负载分担,另外N条链路处于非活动状态作为备份链路,不转发数据。当M条链路中有链路出现故障时,系统会从N条备份链路中选择优先级最高的接替出现故障的链路,同时这条替换故障链路的备份链路状态变为活动状态开始转发数据。静态LACP模式与手工负载分担模式的主要区别为:静态LACP模式有备份链路,而手工负载分担模式所有成员接口均处于转发状态,分担负载流量。在本例中LSW1、LSW2之间共有三条物理链路互联,并且都加入了Eth-trunk,我们将SW1设置为LACP主动端,也就是由它来决策哪些链路是活跃的。在LSW1上,配置了最大活跃链路数为2,所以三条链路中有2条处于活跃状态,另一条则处于备份状态。
验证
LSW1: display eth-trunk 1 #查看链路聚合的状态
LSW2: display eth-trunk 1 #查看链路聚合的状态
当eth0/0/3断掉之后,eth0/0/5可以切换
LSW1: int eth-trunk 1 #进入链路聚合组1 shutdown #关闭接口
display eth-trunk 1 #切换成功