Ubantu实现双网卡主备策略

问题描述:

       近日有需求,服务器用两个网卡互为主备,以提高链路传输的成功率,使得当其中一个网络不通的时候网卡能够自动切换。(Ubantu16)

解决方式

       Linux bonding驱动提供了一个把多个网络接口设备捆绑为单个的网络接口设置来使用,用于网络负载均衡及网络冗余。

步骤:

       1.修改/etc/moduels文件

                 * 在/etc/modules中加入:bonding mode=1 miimon=100

                 * 注意是添加,其他内容不要删除。mode=1表示采用模式1,当然你也可以才用其他模式。

                   miimon是用来进行链路监测的。比如miimon=100,表示系统每100ms监测一次链路连接状态,如果有一条线路不通就切换另一条线路。

       2.修改/etc/network/interfaces文件

auto bond0
iface bond0 inet static
address 10.128.1.12
netmask 255.255.255.0

       3.修改启动脚本

                 * 在启动脚本中加入:ifenslace bond0 enp1s0 enp2s0

                 * enp1s0 enp2s0为待绑定的网卡名

猜你喜欢

转载自super-wangj.iteye.com/blog/2389475