linux下 实践多个网卡 绑定多个bond

环境

系统版本

[root@host1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

四个网卡eth0与eth2是nat模式,绑定到bond0;eth1与eth3是仅主机模式,绑定到bond1

查看内核是否支持bond

[root@host1 ~]# cat /boot/config-3.10.0-1062.el7.x86_64 |grep -i bonding
CONFIG_BONDING=m

网卡配置文件

网卡eth0

[root@host1 network-scripts]# cat ifcfg-eth0 
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
USERCTL=no
SLAVE=yes

网卡eth2

[root@host1 network-scripts]# cat ifcfg-eth2
BOOTPROTO=static
NAME=eth2
DEVICE=eth2
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
USERCTL=no
SLAVE=yes
TYPE=Ethernet

bond0

[root@host1 network-scripts]# cat ifcfg-bond0
BOOTPROTO=static
NAME=bond0
DEVICE=bond0
ONBOOT=yes
#BONDING_MASTER=yes
#BONDING_OPTS="mode=1 miimon=100"
IPADDR=192.168.74.160
NETMASK=255.255.255.0
GATEWAY=192.168.74.2
DNS1=114.114.114.114
TYPE=Ethernet
NM_CONTROLLED=no

网卡eth1

[root@host1 network-scripts]# cat ifcfg-eth1
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond1
USERCTL=no
SLAVE=yes
TYPE=Ethernet

网卡eth3

[root@host1 network-scripts]# cat ifcfg-eth3
BOOTPROTO=static
NAME=eth3
DEVICE=eth3
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond1
USERCTL=no
SLAVE=yes
TYPE=Ethernet

bond1

root@host1 network-scripts]# cat ifcfg-bond1
BOOTPROTO=static
NAME=bond1
DEVICE=bond1
ONBOOT=yes
#BONDING_MASTER=yes
#BONDING_OPTS="mode=1 miimon=100"
IPADDR=192.168.233.129
NETMASK=255.255.255.0
TYPE=Ethernet

加载模块

如果是多个bond需要用max_bonds指定个数

[root@host1 network-scripts]# cat /etc/modprobe.conf 
alias bond0 bonding
options bond0 miimon=100 mode=1 max_bonds=2
alias bond1 bonding
options bond1 miimon=100 mode=1 max_bonds=2

常用模式

  • mode=0 平衡轮询
  • mode=1 主备冗余
posted @ 2021-07-13 10:43  zoer  阅读(335)  评论(0编辑  收藏  举报