bond多网卡绑定

bond多网卡
                 |                                       |
                 |port3                       port3|
+-----+----+                                    +-----+---+
|                |port2                        port2|         |
| switch A +---------------------------+ switch B |
|                |                                 |                 |
+-----+----+                                 +------+---+
                 |port1                        port1|
                 |               +-------+             |
        +------------------+ host1+---------------+
                         eth0 +-------+ eth1

网卡绑定技术有助于保证高可用性特性并提供其它优势以提高网络性能,在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP地址而并行链接聚合成一个逻辑链路工作,这样即使其中的一块物理网卡出现故障,也不会导致连接中断。

网卡绑定就是多张网卡逻辑上作为一张网卡用。可分为,负载均衡绑定和冗余绑定两种。

1、负载均衡:
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.0.100
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
GATEWAY=192.168.0.254
ONBOOT=yes
BOOTPROTO=static
TYPE=BOND #type指网卡类型为bond
BONDING_OPTS="mode=0 miimon=50"  #mode指定模式,miimon为探测的时间间隔(毫秒)

2.编辑各网卡的配置文件
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
MASTER=bond0  #指定master为bond0
SLAVE=yes #是否为附属
USERCTL=no

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

3、加载内核模块
# vim /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=50 mode=0 --mode=[0(banance-rr) | 1(active-backup)]
# modprobe bonding

4、重启服务:
# /etc/init.d/network restart

5、查看
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.1 (October 29, 2006)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:1b:b9:58:8b:b2

Slave Interface: eth1
MII Status: down
Link Failure Count: 0
Permanent HW addr: 00:07:40:6c:ac:c8

如果是7的话需要停止NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl restart network 

猜你喜欢

转载自blog.csdn.net/xinqidian_xiao/article/details/81631389