Linux dual NIC for load balancing (Centos or Ubuntu)

Source: Internet
Author: User

Bind two network cards, share one IP, realize the redundancy effect. In fact, there are 7 types of bindings for Linux dual NICs:

    • The mode=0 indicates that load balancing (round-robin) is balanced, and both NICs work.

    • mode=1 says Fault-tolerance (active-backup) provides redundancy, working in a master-slave way, which means that only one NIC works by default, and the other is backed up.

    • Mode=2 indicates that the XOR policy is a balanced strategy. This mode provides load balancing and fault tolerance

    • Mode=3 indicates that broadcast is a broadcast policy. This mode provides fault tolerance

    • Mode=4 represents the IEEE 802.3ad dynamic Link Aggregation for IEEE 802.3ad as a dynamically linked aggregation. This policy can be changed from the default XOR policy to other policies through the Xmit_hash_policy option.

    • The mode=5 represents Adaptive transmit load balancing for the adapter transport balancing. Required for this pattern: Ethtool supports getting the rate per slave

    • Mode=6 indicates that the Adaptive load balancing is an adaptive load balancer for the adapter. This mode includes the BALANCE-TLB mode, plus receive load balancing for IPV4 traffic (receive load balance, RLB), and does not require any switch (switch) support.


Centos dual NIC for load balancing.

    1. New/etc/sysconfig/network-scripts/ifcfg-bond0 file, vi ifcfg-bond0

Device=bond0onboot=yesbootproto=staticipaddr=192.168.0.23netmask=255.255.255.224gateway=192.168.128.233userctl =no

2. Change/etc/sysconfig/network-scripts/ifcfg-eth0 NIC Properties, VI ifcfg-eth0

Device=eth0onboot=yesbootproto=nonemaster=bond0userctl=no

3. Change the properties of the/etc/sysconfig/network-scripts/ifcfg-eth1 NIC, vi ifcfg-eth1

Device=eth1onboot=yesbootproto=nonemaster=bond0userctl=no

4. Edit the/etc/modprobe.conf file, add the following, VI modprobe.conf

Alias Bond0 bondingoptions bond0 miimon=100 mode=0

ESC Exit Edit: qw! Exit save.


Ubuntu dual NIC for load balancing.

    1. Installing the Load Software

Apt-get Install Ifenslave

2. Load the module and configure the load, Vi/etc/modules

Bonding Mode=0 Miimon=100#miimon is a 10ms monitoring network card status

3. Edit interface, vi/etc/network/interfaces

 # This file describes the network interfaces available on  Your system# and how to activate them. for more information,  see interfaces (5) . # the loopback network interfaceauto loiface  lo inet loopback  #注释掉原来的eth0, eth1 configuration # the primary network interface#auto  eth0#iface eth0 inet dhcp  #auto  eth1#iface eth1 inet dhcp # Here the configuration mode is the polling policy, the pattern code is 0, and the polling interval is 100ms (milliseconds). up ifenslave bond0 eth0 eth1down ifenslave bond0 -d eth0  eth1bond-mode 0bond-miimon 100  #配置bond的IPauto  bond0iface bond0 inet  staticaddress 192.168.0.201netmask 255.255.255.0gateway 192.168.0.1  #配置bond的虚拟IP (not required) auto  bond0:1iface bond0:1 inet staticaddress 192.168.1.201netmask  255.255.255.0gateway 192.168.1.1 

3. Load bonding module, sudo vi/etc/modules

Bonding

4, restart the computer, if successful, bond0, eth0, eth1 MAC address will become the original Eth0 Mac.

sudo shutdown-r now

5. View bonding Status

Cat/proc/net/bonding/bond0


This article is from the "Work Experience record sharing" blog, please be sure to keep this source http://taskkill.blog.51cto.com/879236/1840784

Linux dual NIC for load balancing (Centos or Ubuntu)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.