网卡bond我直接理解成网卡聚合了,就是把多张网卡虚拟成1张网卡,出口时,这张网卡无论哪个断线都不影响网络,入口时,需要结合交换机的端口聚合功能实现和网卡配置的bond模式进行负载均衡。bond需要在内核Kernels 2.4.12及以上才能使用,因为需要使用bonding模块。

bond模式:

bond配置:

1、配置bond

UUID=`uuidgen`
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
UUID=${UUID}
EOF

2、配置两个网卡绑定到bond0中,网卡分别为enp3s0f0、enp3s0f1

cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-enp3s0f0
TYPE="Ethernet"
BOOTPROTO="none"
DEVICE="enp3s0f0"
ONBOOT="yes"
MASTER=bond0
SLAVE=yes
EOF cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-enp3s0f1
TYPE="Ethernet"
BOOTPROTO="none"
DEVICE="enp3s0f1"
ONBOOT="yes"
MASTER=bond0
SLAVE=yes
EOF

3、配置静态IP(可选)

cat <<EOF >> /etc/sysconfig/network-scripts/ifcfg-bond0
BOOTPROTO="static"
IPADDR="192.168.1.10"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.1"
EOF

4、配置bond0到内核加载模块

cat <<EOF > /etc/modprobe.d/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=0 fail_over_mac=1
EOF

fail_over_mac=1参数主要用于当第一张网卡down掉之后,bond0自动获取和更改为第二张网卡的MAC地址。

加载内核

modprobe bonding

5、重启网络服务

service network restart

6、查看网卡的状态:

cat /proc/net/bonding/bond0

7、bond的常用操作命令

主要用于动态增加和删除bond之后的网卡

ifenslave -a

参考(以上内容部分转自下面文章):

http://blog.51cto.com/lixin15/1769338

http://blog.51cto.com/kling/1182260

http://blog.51cto.com/linuxnote/1680315

https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/networking_guide/sec-using_channel_bonding

https://www.lijiawang.org/posts/linux-bond.html

04-24 17:03
查看更多