linux双网卡负载均衡bonding使用方法

Bonding orLAG

You will need netcfg from the Official Repositories, as well as the netcfg-bonding package from the AUR.

Edit/create the following files:

Create /etc/network.d/bonded:

/etc/network.d/bonded
 CONNECTION="bonding"
 INTERFACE="bond0"
 SLAVES="eth0 eth1"
 IP="dhcp"
 DHCP_TIMEOUT=10

Edit your /etc/rc.conf:

/etc/rc.conf
 MODULES=(... bonding ...)
...
 interface=bond0 #comment other lines (address,netmask,gateway,...)
...
 NETWORKS=(... bonded ...)
...
 DAEMONS=(... net-profiles ...) #replace network 

To activate the new bonded ports modprobe bonding, stop network and start the net-profiles service:

# modprobe bonding
# rc.d stop network
# rc.d start net-profiles

系统环境
CentOS 5.3

目前主流的Linux内核(2.6)已经默认支持bonding模块,无需做特别处理。

配置步骤
编写bond0网卡配置
# vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
BOOTPROTO=none
ONBOOT=yes

修改eth0eth1网卡配置
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

加载bonding模块
# vi /etc/modprobe.conf

alias bond0 bonding
options bond0 miimon=100 mode=6

#
: bond optionsmiimon指定了MII连接监控频率(微秒)mode指定bond的策略,6balance-alb模式,此模式不需要交换机特别配置支持,bond的参数具体参考这里

装载bonding模块
# modprobe bonding

重启网络服务
# service network restart

检查配置生效
# cat /proc/net/bonding/bond0
# ifconfig

Manualassignment

You can assign a static IP address in theconsole:

# ip addr add <ip address>/<netmask> dev <interface>

For example:

# ip addr add 192.168.1.2/24 dev eth0

For more options, see: man ip

Add your gateway like so:

# ip route add default via <ip address>

(Substitute your own gateway's IP address)

For example:

# ip route add default via 192.168.1.1

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值