Ubuntu14.04双网卡主备配置

6年前 (2017-12-14) gtj linux, linux基础 0评论 已收录 1034℃

一.linux双网卡的绑定模式的7种模式:

mode=0 表示 load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1 表示 fault-tolerance (active-backup)提供冗余功能,工作方式是主 从的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份。
mode=2 表示 XOR policy 为平衡策略。此模式提供负载平衡和容错能力
mode=3 表示 broadcast 为广播策略。此模式提供了容错能力
mode=4 表示 IEEE 802.3ad Dynamic link aggregation 为 IEEE 802.3ad 为 动态链接聚合。该策略可以通过 xmit_hash_policy 选项从缺省的 XOR 策略改变到其他策略。
mode=5 表示 Adaptive transmit load balancing 为适配器传输负载均衡。该 模式的必要条件:ethtool 支持获取每个 slave 的速率
mode=6 表示 Adaptive load balancing 为适配器适应性负载均衡。该模式包含 了 balance-tlb 模式,同时加上针对 IPV4 流量的接收负载均衡(receive load balance, rlb),而且不需要任何 switch(交换机)的支持。

二.搭建bonding

本实验使用mode6

1.系统版本

cat /etc/issue
Ubuntu 14.04.5 LTS \n \l

2.安装ifenslave软件

sudo vim /etc/apt/sources.list

  1. deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse  
  2. deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse  
  3. deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse  
  4. deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse  
  5. deb http://mirrors.[/sourcecode]sohu.com/ubuntu/ trusty-backports main restricted universe multiverse  
  6. deb-src http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse  
  7. deb-src http://mi[/sourcecode]rrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse  
  8. deb-src http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse  
  9. deb-src http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse  
  10. deb-src http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe 

    3.改配置文件

    选择模式6
    sudo vim /etc/modules
    bonding mode=6 miimon=100
    sudo modprobe bonding

    4.更改interfaces

    sudo vim /etc/network/interfaces
    auto bond0
    iface bond0 inet static
    address 192.168.160.131
    netmask 255.255.255.0
    gateway 192.168.160.2
    dns-nameservers 8.8.8.8
    post-up ifenslave bond0 eth0 eth1
    pre-down ifenslave -d bond0 eth0 eth1
    

    5.重启服务器

    sudo  reboot
    

    6.查看结果

    
    cat /proc/net/bonding/bond0
    Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
    
    Bonding Mode: adaptive load balancing
    Primary Slave: None
    Currently Active Slave: eth0
    MII Status: up
    MII Polling Interval (ms): 100
    Up Delay (ms): 0
    Down Delay (ms): 0
    
    Slave Interface: eth0
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:a7:69:1f
    Slave queue ID: 0
    
    Slave Interface: eth1
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:a7:69:29
    Slave queue ID: 0
    
    

    7.开启关闭bond

    ifup bond0
    ifdown bond0
    

    参考:https://help.ubuntu.com/community/UbuntuBonding

博主

这货来去如风,什么鬼都没留下!!!

相关推荐

嗨、骚年、快来消灭0回复。

Less is more!!!