文章目錄
一:捆綁鏈路原理
1.1:鏈路聚合基本概念
鏈路聚合(Link Aggregation),也稱爲端口捆綁,端口聚集或鏈路聚集。鏈路聚合是將多個端口聚合在一起形成一個匯聚組,以實現出/入負荷在和成員端口中的分擔。從外面看起來,一個匯聚組好像就是一個端口。
使用鏈路匯聚服務的上層實體把同一聚合組內多條物理鏈路視爲一條邏輯鏈路
鏈路聚合在數據鏈路層上實現
1.2:鏈路聚合的優點
如圖:通過將多個物理鏈路捆綁爲一個邏輯鏈路增加了帶寬
提高了可靠性,當有一條鏈路,例如D斷開,流量會自動在剩下的A B C三條鏈路間重新分配
避免二層環路
實現鏈路傳輸彈性和冗餘
1.3:鏈路聚合的限制條件
聚合鏈路兩端的物理參數必須保持一致
1.進行聚合的鏈路的數目要保持一致
2.進行聚合的鏈路的速率要保持一致
3.進行聚合的鏈路爲全雙工方式 要保持一致
聚合鏈路兩端的邏輯參數必須要保持一致
同一個匯聚組中端口的基本配置必須保持一致
基本配置主要包括STP,QoS,VLAN,端口等相關配置
1.4:BPDU(實驗配置中會用到)
BPDU是網橋協議數據單元(Bridge Protocol Data Unit)是一種生成樹協議問候數據包
它以可配置的間隔發出,用來在網絡的網橋間進行信息交換
二:以太網鏈路捆綁
2.1:鏈路捆綁分類:
二層鏈路捆綁
交換機與交換機之間的
二三層鏈路捆綁
交換機與路由器之間的
三層鏈路捆綁
路由器與路由器之間的
2.2:LACP
配置鏈路捆綁是會用到LACP,所以我們必須瞭解LACP
以太網鏈路聚合是指將多條以太網物理鏈路捆綁在一起成爲一條邏輯鏈路,從而實現增加鏈路帶寬的目的。鏈路聚合分爲手工模式和LACP模式
LACP模式需要有鏈路聚合控制協議LACP的參與,當需要在兩個直連設備間提供一個較大的鏈路帶寬而設備支持LACP協議時,建議使用LACP模式。LACP模式不僅可以實現增加帶寬,提高可靠性,負載分擔的目的,而且可以提高Eth-Trunk的容錯性,提供備份功能。
LACP模式下,部分鏈路是活動鏈路,所有活動鏈路均參與數據轉發。如果某條活動鏈路故障,鏈路聚合組自動在非活動鏈路中選擇一條鏈路作爲活動鏈路,參與數據轉發的鏈路數據不變。
三:鏈路捆綁實驗
3.1:實驗拓撲圖
3.2:實驗目的
通過鏈路捆綁實現兩臺主機互聯互通,並在LSW1和LSW2之間 ,三條鏈路,兩個活動,一個備份
3.3 實驗步驟
3.3.1交換機LSW1配置
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw1
Nov 12 2019 16:33:11-08:00 sw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.fo
[sw1]undo info-center enable '//關閉華爲信息提示中心,不建議關閉,我是爲了你們看着方便'
Info: Information center is disabled.
[sw1]lacp priority 1000 '//設置優先級,可理解爲sw1鏈路聚合的接口設置爲“老大”'
[sw1]interface Eth-Trunk1 '//進入接口'
[sw1-Eth-Trunk1]bpdu enable '//開啓BPDU'
[sw1-Eth-Trunk1]mode lacp-static '//設置lacp模式爲靜態LACP'
[sw1-Eth-Trunk1]trunkport e 0/0/1 to 0/0/3 '//將物理接口加入到Eth-Trunk1中'
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1-Eth-Trunk1]max active-linknumber 2 '//設置最大活動鏈路數爲2(原本有三個,即表示爲有一條作爲備用)'
3.3.2:交換機LSW2配置
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw2
Nov 12 2019 16:33:11-08:00 sw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 4, the c
hange loop count is 0, and the maximum number of records is 4095.fo
[sw2]undo info-center enable '//關閉華爲信息提示中心,不建議關閉,我是爲了你們看着方便
Info: Information center is disabled.
[sw2]interface Eth-Trunk1 '//進入接口'
[sw2-Eth-Trunk1]bpdu enable '//開啓BPDU'
[sw2-Eth-Trunk1]mode lacp-static '//設置lacp模式爲靜態LACP'
[sw2-Eth-Trunk1]trunkport e 0/0/1 to 0/0/3 '//將物理接口加入到Eth-Trunk1中'
Info: This operation may take a few seconds. Please wait for a moment...done.
3.3.3:主機配置
3.4:實驗結果
兩臺主機可以成功相互通信
3.5:總結
同一網段的兩臺主機可以直接通過交換機直接通信,不需要通過路由器。
交換機鏈路聚合接口需要有一個設置LACP優先級。還可以在此接口設置最大活動鏈路數量。
每個交換機都要打開bpdu
每個交換機都要設置LACP模式
四:捆綁鏈路+Linux配置Bond
4.1:實驗拓撲圖
4.2:實驗目的
在生產環境中,Linux系統常用兩塊網卡做bond,並實現與主機的互聯互通
4.3:實驗步驟
4.3.1:R1設置
<Huawei>
<Huawei>sys '//進入系統視圖'
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1 '//更改名稱'
Nov 12 2019 16:25:14-08:00 R1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 1, the ch
ange loop count is 0, and the maximum number of records is 4095.n
[R1]undo info-center enable '//關閉華爲信息提示中心,不建議關閉,我是爲了你們看着方便'
Info: Information center is disabled.
[R1]int Eth-Trunk1 '//進入接口'
[R1-Eth-Trunk1]trunkport g 0/0/0 to 0/0/1 '//將物理接口添加進去'
[R1-Eth-Trunk1]ip address 12.0.0.1 30 '//添加ip地址'
[R1-Eth-Trunk1]q
[R1]int Eth-Trunk2 '//進入接口'
[R1-Eth-Trunk2]trunkport g 0/0/2 to 0/0/3 '//將物理接口添加進去'
[R1-Eth-Trunk2]ip add 192.168.10.1 24 '//添加IP地址
4.3.2:R2設置
<Huawei>
<Huawei>sys '//進入系統視圖'
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2 '//更改名稱'
Nov 12 2019 16:25:14-08:00 R2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 1, the ch
ange loop count is 0, and the maximum number of records is 4095.n
[R2]undo info-center enable '//關閉華爲信息提示中心,不建議關閉,我是爲了你們看着方便'
Info: Information center is disabled.
[R2]int Eth-Trunk5 '//進入接口'
[R2-Eth-Trunk5]trunkport g 0/0/0 to 0/0/1 '//將物理接口添加進去'
[R2-Eth-Trunk5]ip address 12.0.0.2 30 '//添加ip地址'
[R2-Eth-Trunk1]ip route-static 192.168.10.0 24 12.0.0.1 '//添加靜態路由
4.3.3:sw1 補全設置
[sw1]int Eth-Trunk2 '//進入接口'
[sw1-Eth-Trunk2]trunkport g 0/0/1 to 0/0/2 '//將物理地址添加進來'
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1-Eth-Trunk2]q '//退出接口'
[sw1]int vlanif 1 '//進入vlan接口'
[sw1-Vlanif1]ip add 192.168.10.2 24 '//添加ip地址'
4.3.4:sw2補全設置
[sw2]int vlanif 1 '//進入vlan接口'
[sw2-Vlanif1]ip add 192.168.10.3 24 '//添加ip地址'
[sw1-Vlanif1]q '//退出接口'
[sw2]int Eth-Trunk2 '//進入接口'
[sw2-Eth-Trunk2]trunkport e 0/0/5 to 0/0/6 '//將物理地址添加進來'
4.3.5:主機補全設置
4.3.6:打開虛擬機,配置
第二步
[root@localhost ~]# nmcli connection '//查看UUID值,準備編輯ens36配置文件'
名稱 UUID 類型 設備
ens33 fe60a0ac-7d04-46a3-b29c-633a50b88f33 802-3-ethernet ens33
virbr0 3f51e6f6-a4d0-4d6c-9df7-48e6e05ff5c6 bridge virbr0
有線連接 1 557ffd5e-8b03-38ce-bffb-17a68e0a8c17 802-3-ethernet ens36 '//新添加的網卡ens36的UUID複製粘貼到其他位置,後面會用'
第三步
[root@localhost ~]# cd /etc/sysconfig/network-scripts/ '//進入網卡配置文件中'
[root@localhost network-scripts]# ls '//查看後發現只有ens33的配置文件'
ifcfg-ens33 ifdown-isdn ifup ifup-plip ifup-tunnel
ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless
ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global
ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions
ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6
ifdown-ib ifdown-Team ifup-ippp ifup-sit
ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team
ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens36 '//我們將ens33的配置文件複製一份'
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort
ifcfg-ens36 ifdown-isdn ifup ifup-plip ifup-tunnel
ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless
ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global
ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions
ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6
ifdown-ib ifdown-Team ifup-ippp ifup-sit
ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team
[root@localhost network-scripts]# vim ifcfg-ens33 '//配置ens33的設置'
第四步
[root@localhost network-scripts]# vim ifcfg-ens36 '//配置ens36’
第五步
[root@localhost network-scripts]# vim ifcfg-bond0 '//配置ifcfg-bond0’
這裏簡單說下bond的模式,詳細的說明可自行百度
mode=0 ,(平衡掄循環策略)
mode=1,(主-備份策略)
mode=2,(平衡策略)
mode=4,( IEEE 802.3ad 動態鏈路聚合,需要交換機配置)
mode=5,
mode=6
miimon:指定MII鏈路監控頻率,單位是毫秒(ms)。這將決定驅動檢查每個slave鏈路狀態頻率。0表示禁止MII鏈路監控。100可以作爲一個很好的初始參考值
第六步
[root@localhost network-scripts]# cd '//返回到家目錄'
[root@localhost ~]# systemctl restart network '//重啓網卡'
[root@localhost ~]# ping 192.168.10.1 '//嘗試與網關通信'
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_seq=1 ttl=255 time=69.5 ms
64 bytes from 192.168.10.1: icmp_seq=2 ttl=255 time=49.7 ms
64 bytes from 192.168.10.1: icmp_seq=3 ttl=255 time=56.0 ms
64 bytes from 192.168.10.1: icmp_seq=4 ttl=255 time=63.9 ms
^C
[root@localhost ~]# ping 192.168.10.4 '//嘗試與PC 1通信'
PING 192.168.10.4 (192.168.10.4) 56(84) bytes of data.
64 bytes from 192.168.10.4: icmp_seq=1 ttl=128 time=119 ms
64 bytes from 192.168.10.4: icmp_seq=2 ttl=128 time=49.7 ms
64 bytes from 192.168.10.4: icmp_seq=3 ttl=128 time=63.5 ms
64 bytes from 192.168.10.4: icmp_seq=4 ttl=128 time=56.0 ms
64 bytes from 192.168.10.4: icmp_seq=5 ttl=128 time=45.0 ms
^C
[root@localhost ~]# ping 192.168.10.5 '//嘗試與PC 2通信'
PING 192.168.10.5 (192.168.10.5) 56(84) bytes of data.
64 bytes from 192.168.10.5: icmp_seq=1 ttl=128 time=68.9 ms
64 bytes from 192.168.10.5: icmp_seq=2 ttl=128 time=42.6 ms
64 bytes from 192.168.10.5: icmp_seq=3 ttl=128 time=35.6 ms
64 bytes from 192.168.10.5: icmp_seq=4 ttl=128 time=27.3 ms
64 bytes from 192.168.10.5: icmp_seq=5 ttl=128 time=40.2 ms
^C
4.4:實驗結果
bond可以和主機通信
4.5:總結
添加bond後需要通過路由器和主機實驗聯通,所以需要配置路由器和足跡網關
lacp命令配置和bpdu命令配置在二層鏈路綁定中使用,同樣,最大鏈路活動數也在此中使用
交換機上配置IP地址需要添加虛擬接口vlanif
Linux新添加的網卡不會自動生成配置文件,我們需要手動複製並配置文件
bond文件也需要手動添加,建議將完整的配置文件保存下來,以後備用