Linux双网卡bonding举例

Linux双网卡bonding举例

http://www.linuxsky.org/doc/admin/200803/288.html

去论坛讨论 来源: 作者:朱峰 发布时间:2008-03-31

所谓bonding,就是将多块网卡绑定同一IP地址对外提供服务,可以实现高可用或者负载均衡。当然,直接给两块网卡设置同一IP地址是不可能的。通过bonding,虚拟一块网卡对外提供连接,物理网卡的被修改为相同的MAC地址。Kernels 2.4.12及以后的版本均提供bonding模块,以前的版本可以通过patch实现。
1.确认你目前使用的网卡,检查/etc/sysconfig/network-scripts目录下以ifcfg-开头的文件,应该为eth0, eth1...
2. 配置虚拟网卡bond0
可以使用DHCP,也可以配置static IP,最好通过vi编辑配置文件

引用

[root@server1 ~]# cd /etc/sysconfig/network-scripts
[root@server1 network-scripts]# cat ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.0.0
NETMASK=255.255.255.0
IPADDR=192.168.0.10
USERCTL=no
GATEWAY=192.168.0.254
TYPE=Ethernet

3. 修改eth0, eth1配置文件

引用

[root@server1 network-scripts]# ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
[root@server1 network-scripts]# ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes

4. 将新添加的bond0设备加入modprobe.conf中,以便kernel识别。加入设置参数,miimon值表示两块网卡相互监测的时间,以ms为单位。mode值为工作模式,可设置为高可用还是负载均衡,0为高可用(默认值),1为负载均衡,另外还有一种XOR模式。

引用

alias bond0 bonding
options bond0 miimon=100 mode=1

关于Linux使用bonding的详细信息可以参考官方文档http://www.kernel.org/pub/linux /kernel/people/marcelo/linux-2.4/Documentation/networking/bonding.txt

原文地址:https://www.cnblogs.com/cute/p/2099438.html