如何进行对多网口的链路聚合配置

Network eth

在Linux 服务器下进行多网口的 负载均衡

  1. 插件安装
apt-get install ifenslave
  1. 配置interfaces
auto lo bond0 eth0 eth1
iface bond0 inet static
address 192.168.4.134
netmask 255.255.255.0
network 192.168.4.0
broadcast 192.168.4.255
gateway 192.168.4.1
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1
# The primary network interface
iface lo inet loopback
iface eth0 inet static
address 192.168.4.135
netmask 255.255.255.0
iface eth1 inet static
address 192.168.4.136
netmask 255.255.255.0

3、把bond模块加入到/etc/modules

alias bond0 bonding
options bond0 mode=balance-alb miimon=100 max_bonds=2

说明:miimon是用来进行链路监测的。 比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。
mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.
bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用 .
4、重启网卡
5、加入开机启动

modprobe bonding max_bonds=2

创建一个bond设备,三个简单的步骤即可搞定:
(1)首先要保证相应的驱动程序已经加载:

localhost@root ~# modprobe bonding

modprobe <3c59x| eepro100|pcnet32|tulip|...>

(2)其次给等梆定bond设备分配IP地址

localhost@root ~# ifconfig bond0 <IP地址> netmask <子网掩码> broadcast <广播地址 >

例如

 ifconfig bond0 192.168.1.242 netmask 255.255.255.0 broadcast 
172.31.3.254

(3)最后将所有要梆定的物理网卡接口添加到bond设备中去

localhost@root ~# ifenslave bond0 [{-f|--force} bond0 eth0 [ eth1 [eth2]...]

例如

ifenslave bond0 eth0 eth1

梆定了eth0 eth1两个网卡设备。 --force 表示强制进行梆

创建好bond设备后,就可以像一般的网卡设备一样使用了
如启动bond0: # ifconfig bond0 up
停用bond0: # ifconfig bond0 down
在不停用bond0的情况下添加接口: # ifenslave {-d| --detach} bond0 eth0 [eth1 [eth2]...]
--detach表示"附加"的意思
改变活动的从设备: # ifenslave {-c|--change-active} bond0 eth0
--change-acitve 表示"改变活动的从设备"的意思
显示主接口(指bond0)信息: # ifenslave bond0
显示所以接口信息: # ifenslave {-a|--all-interfaces}
--all-interfaces 表示"所有接口"

转载于:https://www.cnblogs.com/Qingluan/p/5137134.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值