在華爲上實現二三層的負載均衡和備份
實驗拓撲圖:
實驗原理:
1.以太網鏈路捆綁技術主要有2種:lacp模式和手動捆綁模式。
2.以太網鏈路捆綁技術主要作用:最大限度利用鏈路帶寬和提供鏈路的負載備份。
實驗目標:
1.在華爲設備上使用lacp協議實現二層的負載均衡和備份
2.在華爲設備上使用手動捆綁實現三層的負載均衡和備份
實驗步驟:
接口 | trunk口 | IP地址 |
C1 | 192.168.1.10 | |
C2 | 192.168.2.20 | |
sw1 e0/0/2,e0/0/3,e0/0/4 | eth-trunk 1 | |
sw2 g0/0/1,g0/0/2 | eth-trunk 2 | |
R1 g0/0/0,g0/0/1 | eth-trunk 1 | |
eth-trunk 1.1 | 192.168.1.1 | |
g0/0/2,g2/0/0 | eth-trunk 2 | 192.168.2.1 |
R2 g0/0/0,g0/0/1 | eth-trunk 1 | 192.168.2.2 |
SW1
[SW1]int Eth-Trunk 1
[SW1-Eth-Trunk1]bpduenable 開啓bpdu
[SW1-Eth-Trunk1]modelacp-static 定義爲lacp-static模式
[SW1-Ethernet0/0/2]inte0/0/2
[SW1-Ethernet0/0/2]eth-trunk1
[SW1]int e0/0/3
[SW1-Ethernet0/0/3]eth-trunk1
[SW1]int e0/0/4
[SW1-Ethernet0/0/4]eth-trunk1
---------------------------以上將端口加入eth-trunk 1 組 -----------------
[SW1]lacp priority 100 定義SW1的lacp優先級爲100使其成爲lacp協議主設備
[SW1]int Eth-Trunk 1
[SW1-Eth-Trunk1]maxactive-linknumber 2 定義eth-trunk 1組的最大活躍鏈路數爲2
SW2
[SW2]int Eth-Trunk 1
[SW2-Eth-Trunk1]bpduenable
[SW2-Eth-Trunk1]modelacp-static
[SW2]int e0/0/2
[SW2-Ethernet0/0/2]eth-trunk1
[SW2]int e0/0/3
[SW2-Ethernet0/0/3]eth-trunk1
[SW2]int e0/0/4
[SW2-Ethernet0/0/4]eth-trunk1
結果驗證:
在SW1上使用displayeth-trunk 1命令可以看到e0/0/4因爲端口號最大根據lacp選舉原則成爲備份端口,e0/0/2和e0/0/3成爲轉發端口,負載都爲1,實現了鏈路的負載均衡。
在PC1上ping 192.168.1.20 -t (PC2)可以通信
將PC1的e0/0/3接口shutdown,再次查看eth-trunk 1,可以看到e0/0/3狀態轉爲unselect不承載流量,而e0/0/4狀態轉爲selected轉發流量,通信過程因爲轉發端口的切換而短暫丟了一個包,通信基本不受影響,實現了二層鏈路的負載及備份。
3.三層以太網鏈路捆綁
R1
[R1]int Eth-Trunk 2
[R1-Eth-Trunk2]undoportswitch 使eth-trunk 2 變爲3層
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]eth-trunk2
[R1]int g2/0/0
[R1-GigabitEthernet2/0/0]eth-trunk2
[R1]int Eth-Trunk 2
[R1-Eth-Trunk2]ipaddress 192.168.2.1 24 配置eth-trunk 2的ip地址
R2
[R2]int Eth-Trunk 1
[R2-Eth-Trunk1]undoportswitch
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]eth-trunk1
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]eth-trunk1
[R2]int Eth-Trunk 1
[R2-Eth-Trunk1]ip add192.168.2.2 24
結果驗證:
在R1上可以看到兩個接口狀態都爲up且負載相同,pingR2可以通信
把R2的g0/0/1接口shutdown,R1與R2仍然可以通信,實現了三層鏈路的負載及備份