centos 7 配置多网卡bond

2019-08-19

centos 7 配置多网卡bond,网卡绑定mode共有七种(0~6) bond0、bond1、bond2、bond3、bond4、bond5、bond6(常用的有三种)

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。
mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。
mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定

1、关闭 NetworkManager 服务

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

2、配置网卡1

vim /etc/sysconfig/network-scripts/ifcfg-eno24
TYPE=Ethernet
BOOTPROTO=none
USERCTL=no
DEVICE=eno24
ONBOOT=yes
MASTER=bond0
SLAVE=yes

配置网卡2

vim /etc/sysconfig/network-scripts/ifcfg-eno25
TYPE=Ethernet
BOOTPROTO=none
USERCTL=no
DEVICE=eno25
ONBOOT=yes
MASTER=bond0
SLAVE=yes

3、配置bond

vim /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Bond
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
DEVICE=bond0
IPADDR=192.168.1.4
PREFIX=24
GATEWAY=192.169.1.254
NM_CONTROLLED=no
BONDING_MASTER=yes

5、加bonding内核模板

modprobe --first-time bonding
lsmod | grep bonding 或者 modinfo bonding

6、配置bonding驱动

(实践该步骤未做,便可用)
vim /etc/modprobe.d/bond.conf
alias bond0 binding
options bond0 miimon=100 mode=1

7、重启网络服务

service network restart

查看bond0生效

cat /proc/net/bonding/bond0

8、配置dns

vim /etc/resolv.conf
nameserver 202.106.0.20

9、centos 7默认启动时没有加载bonding模块

# 查看bonding模块详细信息
modinfo bonding
filename /lib/modules/3.10.0-229.el7.x86_64/kernel/drivers/net/bonding/bonding.ko

# 配置系统启动时加载bonding模块
vim /etc/sysconfig/modules/bonding.modules
#!/bin/sh
/sbin/modinfo -F filename bonding > /dev/null 2>&1
if [ $? -eq 0 ];then
/sbin/modprobe bonding
fi

# 设置执行权限
chmod 755 /etc/sysconfig/modules/bonding.modules
# 重启查看是否生效
reboot

10、nmcli

systemctl NetworkManager start

nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup

nmcli connection add type bond-slave ifname em1 master bond0
Connection 'bond-slave-em1' (9cf3468a-3425-4d6a-a4c3-d647a1a5ea92) successfully added.

nmcli connection modify bond0 ipv4.addresses 192.168.100.100/24 ipv4.method manual

nmcli connection up bond-slave-em1
nmcli connection up bond-slave-em2
nmcli connection up bond0
#############
nmcli connection down bond0
nmcli connection delete bond0
nmcli connection delete bond-slave-em1
nmcli connection delete bond-slave-em2
11、网络组:是将多个网卡聚合在一起方法,从而实现冗错和提高吞吐量;网络组不同于旧版中bonding技术,提供更好的性能和扩展性;网络组由内核驱动和teamd守护进程实现。

nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
nmcli connection add type team-slave ifname em1 master team0
nmcli connection add type team-slave ifname em2 master team0
nmcli connection modify team0 ipv4.addresses 192.168.100.100/24 ipv4.method manual

nmcli connection up team-slave-em1
nmcli connection up team-slave-em2
nmcli connection up team0
teamctl team0 state

#############
nmcli connection down team0
nmcli connection down team-slave-em1
nmcli connection down team-slave-em2

nmcli connection delete team0
nmcli connection delete team-slave-em1
nmcli connection delete team-slave-em2

分类:Linux | 标签: |

相关日志

评论被关闭!