1. 程式人生 > >雙網卡mode6模式 同時工作 冗余互備

雙網卡mode6模式 同時工作 冗余互備

mon pack 配置環境 速度 use loopback AC rri The

1.1、添加雙網卡,正常工作時他們會共同傳輸數據,使得網絡傳輸的速度更快,mode6模式即使有一塊網卡出現了故障,另一塊會自動頂替上去,保證數據傳輸不會中斷

1.2、網卡綁定驅動的三種模式 mode0 mode1 mode6

mode0:(平衡負載模式):平時兩塊網卡均工作,且自動備援,但需要在與服務器本地網卡相連的交換機設備上進行端口聚合來支持綁定技術

mode1:(自動備援模式):平時只有一塊網卡工作,在它故障後自動替換為另外的網卡

mode6:(平衡負載模式):平時兩塊網卡均工作,且自動備援,無需交換機設備提供輔助支持

1.3、雙網卡的mode6模式配置環境

環境:CentOS7.5

# cat /etc/redhat-release

CentOS Linux release 7.5.1804 (Core)

1.4、配置雙網卡的mode6模式

為服務器或虛擬機添加雙網卡,服務器內網或外網,虛擬機網卡添加相同的模式橋接或nat

配置過程:

配置網卡1:ens33

cd /etc/sysconfig/network-scripts/

vim ifcfg-ens33

DEVICE=ens33

BOOTPROTO=static

ONBOOT=yes

MASTER=bond0

SLAVE=yes

USERCTL=no

配置網卡2:ens36

cd /etc/sysconfig/network-scripts/

vim ifcfg-ens36

DEVICE=ens36

BOOTPROTO=static

ONBOOT=yes

MASTER=bond0

SLAVE=yes

USERCTL=no

配置網卡bond0

cd /etc/sysconfig/network-scripts/

vim ifcfg-bond0

DEVICE=bond0

BONDING_OPTS="mode=6 miimon=100"

BOOTPROTO=static

ONBOOT=yes

IPADDR=192.168.1.200

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

DNS1=192.168.1.1

DNS2=114.114.114.114

USERCTL=no

在創建一個文件並寫入一行配置

vim /etc/modprobe.d/bonding.conf

alias bond0 bonding

進行檢查是否加載了 bonding 模塊

# lsmod |grep bonding

bonding 149864 0

如果沒有加載,進行加載

modprobe bonding

重啟網卡

systemctl restart network

1.5、檢查配置情況

# ifconfig

bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500

inet 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255

ether 00:0c:29:b5:51:e8 txqueuelen 1000 (Ethernet)

RX packets 2410 bytes 212984 (207.9 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 4708 bytes 367636 (359.0 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33: flags=6147<UP,BROADCAST,SLAVE,MULTICAST> mtu 1500

ether 00:0c:29:b5:51:de txqueuelen 1000 (Ethernet)

RX packets 2004 bytes 182078 (177.8 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 928 bytes 144401 (141.0 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens36: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500

ether 00:0c:29:b5:51:e8 txqueuelen 1000 (Ethernet)

RX packets 2976 bytes 262465 (256.3 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 4708 bytes 367636 (359.0 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10<host>

loop txqueuelen 1000 (Local Loopback)

RX packets 353 bytes 101528 (99.1 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 353 bytes 101528 (99.1 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500

inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255

ether 52:54:00:2e:2f:38 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 0 bytes 0 (0.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

查看網卡流量信息

cat /proc/net/bonding/bond0

找一臺機器進行ping,並斷掉本機其中一塊網卡觀察是否正常接管

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

請求超時。

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64

來自 192.168.1.200 的回復: 字節=32 時間<1ms TTL=64


雙網卡mode6模式 同時工作 冗余互備