1. 程式人生 > >網絡卡鏈路聚合之bond

網絡卡鏈路聚合之bond

什麼是網絡卡鏈路聚合

網絡卡鏈路聚合可以有效地防止當一塊網絡卡損壞後,依舊可以繼續訪問網路,同時提高了網速。

配置

1.配置網絡卡

首先給虛擬機器配置兩塊網絡卡
這裡寫圖片描述

2.刪除所有網路配置

nm-connection-editor ##刪除eth0網路配置
此時可以看出eth0和eth1都沒有配置網路
這裡寫圖片描述

3.設定鏈路聚合

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.141/24 ##設定bond0鏈路,ip為172.25.254.141


這裡寫圖片描述

4.新增網絡卡

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 ##給bond0新增網絡卡eth0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 ##給bond0新增網絡卡eth1
這裡寫圖片描述

5.監控

watch -n 1 cat /proc/bonding/bond0 ##監控bond0狀態
這裡寫圖片描述

測試

ifconfig eth0 down ##關閉eth0網絡卡
發現依舊在ping,沒有任何影響,但bond0的工作網絡卡換為eth1
這裡寫圖片描述

反之
ifconfig eth0 up ##開啟eth0網絡卡
ifconfig eth1 down ##關閉eth0網絡卡
依舊能ping,沒有任何影響,只有bond0的工作網絡卡切換了
這裡寫圖片描述