配置Centos8網絡綁定
原理: 在物理網卡兩塊之上創建一塊虛擬主卡, 邏輯上是一主雙從, 按不同的模式負載運行,常用模式如主備或並行提供雙倍帶寬等。
模式: 可選參數"mode=active-backup", atcive-bakcp或1皆可.
0 - balance-rr 需要啟用靜態的 Etherchannel(未啟用 LACP 協商)
1 - active-backup 需要可自主端口
2 - balance-xor 需要啟用靜態的 Etherchannel(未啟用 LACP 協商)
3 - broadcast 需要啟用靜態的 Etherchannel(未啟用 LACP 協商)
4 - 802.3ad 需要啟用 LACP 協商的 Etherchannel
5 - balance-tlb 需要可自主端口
6 - balance-alb 需要可自主端口
1、部署雙網卡, 注意以下操作必須在本機控制台操作.
2、配置模式為主備, 平時只激活一塊網卡, 損壞時會自動激活另一塊, 配置如下:
nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup"
nmcli connection add type ethernet slave-type bond con-name eth0 ifname eth0 master bond0
nmcli connection add type ethernet slave-type bond con-name eth1 ifname eth1 master bond0
nmcli connection modify bond0 ipv4.addresses '192.168.1.7/24'
nmcli connection modify bond0 ipv4.gateway '192.168.1.1'
nmcli connection modify bond0 ipv4.dns '114.114.114.114'
nmcli connection modify bond0 ipv4.method static
nmcli connection up bond0
nmcli device status
cat /proc/net/bonding/bond0
配置好的三塊網卡配置文件應如下:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
NAME=eth0
UUID=7aca14c5-d58b-4917-8310-b0a363c554cf
DEVICE=eth0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
vim /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
NAME=eth1
UUID=ddb63ef8-f2fb-4053-bf8a-0a429dfc9072
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
vim /etc/sysconfig/network-scripts/ifcfg-bond0
BONDING_OPTS="mode=1 miimon=100"
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=bond0
UUID=c722a481-fb43-446e-9e91-6a63f0078711
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.1.7
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
3、啟動Linux內核對網卡綁定驅動的支持,常見模式三種:
mode0(平衡負載模式):平時兩塊網卡均工作,且自動備援,但需要在與服務器本地網卡相連的交換機設備上進行端口聚合來支持綁定技術。
mode1(自動備援模式):平時只有一塊網卡工作,在它故障后自動替換為另外的網卡。
mode6(平衡負載模式):平時兩塊網卡均工作,且自動備援,無須交換機設備提供輔助支持。
#配置好bond0網卡的綁定模式后重啟網絡服務即可成功
systemctl restart NetworkManager
nmcli c reload
nmcli d status
#查看一下網絡配置,正常情況下只有網卡bond0才會有IP地址信息
ifconfig