概述:
通过网卡绑定,处理网卡单点故障,实验的操作系统是Redhat Linux Enterprise 5.3.
绑定的前提条件:芯片组型号相同,而且网卡应该具备自己独立的BIOS芯片。
网卡绑定时有四种模式,其中常用的是模式0和模式1:
模式0(轮循模式):负载均衡工作模式,他能提供两倍的带宽 ,这种情况下出现一块网卡失效,仅仅会是服务器出口带宽下降,也不会影响网络使用.
模式1(主备模式):当一个网络接口失效时(例如主交换机掉电等),不会出现网络中断,系统会按照cat /etc/rc.local里指定网卡的顺序工作,机器仍能对外服务,起到了失效保护的功能
案例:
模式1
1. modprobe bonding //调用模块bonding
modinfo bonding    //查看内核中加载的模块相关参数
内容:
  1. filename: /lib/modules/2.6.25.19/kernel/drivers/net/bonding/bonding.ko
2.编辑虚拟网络接口配置文件,指定网卡IP
注意:不要指定单个网卡的IP 地址、子网掩码或网卡 ID。将上述信息指定到虚拟适配器(bonding)中即可。
cd /etc/sysconfig/network-scripts/
vim ifcfg-eth0 //模块别名
内容:
  1. DEVICE=eth0 //设备
  2. BOOTPROTO=dhcp //自动获取地址
  3. ONBOOT=yes   //启动激活
vim ifcfg-eth1
内容:
  1. DEVICE=eth1
  2. BOOTPROTO=dhcp
  3. ONBOOT=yes
cp ifcfg-eth0 ifcfg-bond0
vim ifcfg-bond0 //编辑额外的网卡
内容:
  1. DEVICE=bond0
  2. BOOTPROTO=none
  3. IPADDR=192.168.2.101
  4. NETMASK=255.255.255.0
  5. ONBOOT=yes
3.vim /etc/modprobe.conf //编辑模块配置文件,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0
内容加入二行:
  1. alias bond0 bonding   //内核模块
  2. options bond0  miimon=100 //链路监测 mode=1 //工作模式

4.vim /etc/rc.local

内容加入一行:
  1. ifenslave bond0 eth0 eth1

配置完毕,重新启动电脑

1.Xshell:\> ping 192.168.2.101
  1. Pinging 192.168.2.101 with 32 bytes of data:
  2. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  3. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  4. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  5. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  6. Ping statistics for 192.168.2.101:
  7. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  8. Approximate round trip times in milli-seconds:
  9. Minimum = 0ms, Maximum = 0ms, Average = 0ms
2.ifconfig  //查看网卡信息
  1. bond0     Link encap:Ethernet HWaddr 00:0C:29:9E:49:28
  2. inet addr:192.168.2.101 Bcast:192.168.2.255 Mask:25
  3. 5.255.255.0
  4. inet6 addr: fe80::20c:29ff:fe9e:4928/64 Scope:Link
  5. UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
  6. RX packets:87 errors:0 dropped:0 overruns:0 frame:0
  7. TX packets:122 errors:0 dropped:0 overruns:0 carrier:0
  8. collisions:0 txqueuelen:0
  9. RX bytes:13696 (13.3 KiB) TX bytes:24910 (24.3 KiB)
  10. eth0      Link encap:Ethernet HWaddr 00:0C:29:9E:49:28
  11. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
  12. RX packets:73 errors:0 dropped:0 overruns:0 frame:0
  13. TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
  14. collisions:0 txqueuelen:1000
  15. RX bytes:10395 (10.1 KiB) TX bytes:19299 (18.8 KiB)
  16. Interrupt:19 Base address:0x2000
  17. eth1      Link encap:Ethernet HWaddr 00:0C:29:9E:49:28
  18. UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
  19. RX packets:14 errors:0 dropped:0 overruns:0 frame:0
  20. TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
  21. collisions:0 txqueuelen:1000
  22. RX bytes:3301 (3.2 KiB) TX bytes:5611 (5.4 KiB)
3.cat /proc/net/bonding/bond0 //查看内核信息
  1. Bonding Mode: fault-tolerance (active-backup)
  2. Primary Slave: None
  3. Currently Active Slave: eth0
  4. MII Status: up
  5. MII Polling Interval (ms): 100
  6. Up Delay (ms): 0
  7. Down Delay (ms): 0
  8. Slave Interface: eth0
  9. MII Status: up
  10. Link Failure Count: 0
  11. Permanent HW addr: 00:0c:29:9e:49:28
  12. Slave Interface: eth1
  13. MII Status: up
  14. Link Failure Count: 0
  15. Permanent HW addr: 00:0c:29:9e:49:32

断开网卡eth0后:

1.Xshell:\> ping 192.168.2.101 -t
  1. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  2. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  3. Request timed out.
  4. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
  5. Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
2.cat /proc/net/bonding/bond0 
  1. Bonding Mode: fault-tolerance (active-backup)
  2. Primary Slave: None
  3. Currently Active Slave: eth1
  4. MII Status: up
  5. MII Polling Interval (ms): 100
  6. Up Delay (ms): 0
  7. Down Delay (ms): 0
  8. Slave Interface: eth0
  9. MII Status: down
  10. Link Failure Count: 1
  11. Permanent HW addr: 00:0c:29:9e:49:28
  12. Slave Interface: eth1
  13. MII Status: up
  14. Link Failure Count: 0
  15. Permanent HW addr: 00:0c:29:9e:49:32
断开网卡eth1后:
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64 Reply from 192.168.2.101: bytes=32 time<1ms TTL=64 Request timed out.  Reply from 192.168.2.101: bytes=32 time<1ms TTL=64 Reply from 192.168.2.101: bytes=32 time<1ms TTL=64 
模式0
注意:只需修改模块配置文件就可以,其它配置与模式1一样
1.vim /etc/modprobe.conf //编辑模块配置文件

文件内容修改一行:
  1. options bond0 miimon=100 mode=0
配置完毕,重新启动电脑 
断开网卡eth0后:
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Request timed out.
Request timed out.
Request timed out.
断开网卡eth1后:
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Request timed out.
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64
Reply from 192.168.2.101: bytes=32 time<1ms TTL=64

转载于:https://blog.51cto.com/yz406/962510

Linux双网卡绑定实现相关推荐

  1. Linux 双网卡绑定测试

    Linux 双网卡绑定测试 先介绍一下情况,服务器A和服务器B都是CentOS 4.6的系统,现在要做HA Cluster,为了避免裂脑的发生,要提高心跳链路的可靠性,下图是现时的连接情况,服务器A的 ...

  2. linux双网卡绑定实现冗余与负载均衡

    linux双网卡绑定实现冗余与负载均衡 1 编辑/etc/modprobe.conf   在/etc/modprobe.conf里加入如下两行: alias bond0 bonding options ...

  3. linux更换网卡不识别_详解Linux双网卡绑定脚本的方法示例

    概述 linux运维及配置工作中,常常会用到双网卡绑定,少数几台服务器的配置还好,如果是需要配置几十甚至上百台,难免会枯燥乏味,易于出错,我编写了这个双网卡绑定的辅助脚本,可傻瓜式地完成linux双网 ...

  4. linux 双网卡浮动ip,Linux 双网卡绑定一个IP原理及实现

    我们在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP地址而并行链接聚合成一个逻辑链路工作.其实 ...

  5. Linux双网卡绑定

    Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP地址而并行链接聚合成一个逻辑链路工作.其实这项技术在Su ...

  6. linux 双网卡绑定(bonding)实现负载均衡或故障转移

    linux 双网卡绑定(bonding)实现负载均衡或故障转移 我们在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是 ...

  7. Linux 双网卡绑定

    Linux 双网卡绑定 Linux 双网卡绑定 双网卡绑定的常用模式: mode1:active-backup 模式,即主备模式. mode0:round-broin 模式,即负载均衡模式(需要交换机 ...

  8. 设置双网卡mic linux,linux双网卡绑定为逻辑网卡

    网卡bond是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡,在生产场景中是一种常用的技术. 生产环境服务器为:DELL 网卡为:光纤 bond需要修改涉及的网卡配置文件 /e ...

  9. linux配置网卡绑定后不生效,Linux双网卡绑定实现负载均衡和失效保护

    在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的IP地址而并行链接聚合成一个逻辑链路工作.其实这项 ...

  10. suse linux双网卡绑定,suse linux双网卡绑定设置详解

    <suse linux双网卡绑定设置详解>由会员分享,可在线阅读,更多相关<suse linux双网卡绑定设置详解(2页珍藏版)>请在人人文库网上搜索. 1.suse linu ...

最新文章

  1. 我所理解的Spring AOP的基本概念
  2. linux同步到对象存储,将Cpanel备份配置为S3对象存储的方法
  3. 数组去重--这几种方法够不?
  4. print arraylist 显示的不是内容_泛型数组列表 java.util.ArrayListlt;Egt;
  5. 行业薪酬大跳水 区块链真的凉了?
  6. vscode编辑器tab换行缩进问题
  7. vnc数量限制_通过限制视觉效果在Vista上加速VNC
  8. 精通java益处_你真的精通Java吗?
  9. NSThread使用总结
  10. 十二星座PSD分层海报,治愈心灵,谁见谁爱!
  11. OracleBulkCopy的批量数据导入
  12. (转)LuaPlus C++ 函数互调
  13. 移动端页面rem布局出现横向滚动条的修复
  14. 学科领域本体关系数据与可视化
  15. 算法:二叉平衡树(AVL树)
  16. 敏感词工具(sensitive word)的使用
  17. android 筛选电影,Movie - 该看什么电影呢?这几个小程序或许能给你一个选择 - Android 应用 - 【最美应用】...
  18. Python温习(六)——元组操作
  19. 小强升职记-一本好书
  20. 拼多多退款怎么设置?万顿思教育

热门文章

  1. linux命令行界面下ctrl 常用组合键速查表
  2. vim多列操作--插入/删除
  3. 资深大牛带你了解源码!关于Android程序员最近的状况,大厂内部资料
  4. manjaro linux 关机,给本子安装manjaro 出现无法关机的解决办法
  5. docker在Centos上的安装
  6. Find a girl friend
  7. Centos7下使用ELK(Elasticsearch + Logstash + Kibana)搭建日志集中分析平台
  8. 图的四种最短路径算法
  9. 深度学习笔记之win7下TensorFlow的安装
  10. PE文件感染和内存驻留