title, date, lastmod, keywords, tags, categories
title |
date |
lastmod |
keywords |
tags |
categories |
CentOS7 双网卡绑定 |
2019-10-30T11:07:30+08:00 |
2019-10-30T11:07:30+08:00 |
|
|
|
bond 概要
什么是 bond
- 网卡bond是通过把多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡。在应用部署中是一种常用的技术。
bond的模式种类
- Mode=0(balance-rr) 表示负载分担round-robin,和交换机的聚合强制不协商的方式配合
- Mode=1(active-backup) 表示主备模式,只有一块网卡是active,另外一块是备的standby
- 如果交换机配的是捆绑,将不能正常工作,因为交换机往两块网卡发包,有一半包是丢弃的
- Mode=2(balance-xor) 表示XOR Hash负载分担,和交换机的聚合强制不协商方式配合(需要xmit_hash_policy)
- Mode=3(broadcast) 表示所有包从所有interface发出,这个不均衡,只有冗余机制...和交换机的聚合强制不协商方式配合
- Mode=4(802.3ad) 表示支持802.3ad协议,和交换机的聚合LACP方式配合(需要xmit_hash_policy)
- Mode=5(balance-tlb) 是根据每个slave的负载情况选择slave进行发送,接收时使用当前轮到的slave
- Mode=6(balance-alb) 在5的tlb基础上增加了rlb
CentOS7 配置 bond
环境
- 操作系统 CentOS7.6,禁用 NetworkManager 服务
- 物理网卡 eth0, eth1 绑定到 bond0
- 物理网卡 eth2, eth3 绑定到 bond1
网卡 eth0 配置
网卡 eth1 配置
网卡 eth2 配置
网卡 eth3 配置
增加网卡 bond0 配置
增加网卡 bond1 配置
配置绑定模式
载入 bonding 模块,重启 network 服务
modprobe bonding
systemctl restart network
查看网卡绑定状态
cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1
CentOS8 配置 bond
- 建立 bond 连接配置文件
nmcli c add con-name bond0 type bond ifname bond0 mode active-backup
- 增加两个网卡都 bond0
nmcli c add type bond-slave ifname eth1 master bond0
nmcli c add type bond-slave ifname eth2 master bond0
- 启动这两个 slave 连接
nmcli c up bond-slave-eth1
nmcli c up bond-slave-eth2