• Linux下双网卡绑定bond0【转】


    一:原理:

    linux操作系统下双网卡绑定有七种模式。现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同时又能做相应的冗余,可以说是好处多多。而一般企业都会使用linux操作系统下自带的网卡绑定模式,当然现在网卡产商也会出一些针对windows操作系统网卡管理软件来做网卡绑定(windows操作系统没有网卡绑定功能 需要第三方支持)。进入正题,linux有七种网卡绑定模式:0. round robin,1.active-backup,2.load balancing (xor),  3.fault-tolerance (broadcast), 4.lacp,  5.transmit load balancing, 6.adaptive load balancing。

    二:案例一mode=1(active-backup):一个网卡处于活动状态 ,一个处于备份状态,所有流量都在主链路上处理。当活动网卡down掉时,启用备份的网卡。

    1:[root@lyt ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0           #编辑该设备eth0如图:

    image

    [root@lyt ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1            #编辑该设备eth1 如图:

    image

    2:[root@lyt ~]# cd /etc/sysconfig/network-scripts/

    [root@lyt network-scripts]# cp ifcfg-eth0  ifcfg-bond0        #生成一个bond0的虚拟网卡

    [root@lyt network-scripts]# vim ifcfg-bond0        #编辑该网卡内容

    image

    3:[root@lyt network-scripts]# vim /etc/modprobe.conf       #编辑该配置文件

    下图中1表示系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0;miimon=100表示系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线

    路;mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份。

    image

    4:[root@lyt network-scripts]# vim /etc/rc.local        #编辑该开机脚本,将eth0和eth1网卡进行绑定

    image

    5:[root@lyt network-scripts]# init 6       #重启,bond0启动成功

    image

    [root@lyt ~]# ifconfig      #查看网卡信息,在此处三块网卡的mac地址是一样的

    image

    [root@lyt ~]#vim /proc/net/bonding/bond0      #查看模式及网卡信息。实际mac地址是不一样的

    image

    测试:

    6:Xshell:> ping 192.168.101.50  –t      #一直测试网络的连通性查看结果

    断掉eth0网卡后显示结果

    image

    将网卡eth0断掉后,系统使用备份网卡eth1,此时eth1处于活动状态

    image

    案例二:mode=0(round robin):所有链路处于负载均衡状态,这模式的特点增加了带宽,同时支持容错能力。

    1:在案例一的基础上,只需要修改/etc/modprobe.conf 配置文件:如图:

    image

    2:vim /proc/net/bonding/bond0        #查看使用的模式及网卡信息,如图:

    image 

    测试:mode=0:

    3:Xshell:> ping 192.168.101.50 –t #一直测试网络的连通性查看结果

    将网卡eth1断掉后,系统依然可以ping通

    image

    image

    本文出自 “. . .” 博客,请务必保留此出处http://5503845.blog.51cto.com/5493845/96258

  • 相关阅读:
    系统维护相关问题
    Python环境维护
    哈希表解决字符串问题
    论文笔记二:《A Tutoral on Spectral Clustering》
    论文笔记之哈希学习比较--《Supervised Hashing with Kernels》《Towards Optimal Binary Code Learning via Ordinal Embedding》《Top Rank Supervised Binary Coding for Visual Search》
    Java中String、StringBuffer、StringBuilder的比较与源 代码分析
    浙大pat1040 Longest Symmetric String(25 分)
    浙大pat1039 Course List for Student(25 分)
    浙大pat---1036 Boys vs Girls (25)
    百炼oj-4151:电影节
  • 原文地址:https://www.cnblogs.com/seaspring/p/6708281.html
Copyright © 2020-2023  润新知