Implementation of multi-IP and bongding for Linux single-NIC binding

Source: Internet
Author: User

The concept of Linux Bond1 bond
Linux dual-NIC binding implementation is the use of two network card virtual become a network card, the aggregation of the device appears to be a separate Ethernet interface device, the popular point is that two network cards with the same IP address and parallel link aggregation into a logical link work.
2 The origins of bond technology
This technology, known as trunking and EtherChannel technology, has long existed in sun and Cisco, and is also known as bonding in Linux's 2.4.x kernel.
3 How Bond works
Under normal circumstances, the network card only receives the destination hardware address (MAC addresses) is the Ethernet frame of its own Mac, filtering out other data frames to reduce the burden on the driver. But the network card also supports another kind called promiscuous Promisc mode, can receive all the frames on the network, bonding also runs in this mode, and modifies the MAC address in the driver, the MAC address of the two NIC is changed to the same, can receive the data frame of the specific Mac. The corresponding data frames are then routed to the bond driver for processing.
4 Bond file Configuration
See if A is supported. vim/etc/modprobe.d/bonding.conf alias Bond0 Bonding---To enable the system to load the bonding module at startup, the external virtual network interface device is bond0options bond0 miimon=100 m Ode=1 Description: Miimon is used for link monitoring.  For example: miimon=100, then the system every 100MS monitoring link connection status, if one line is not connected to another line; Mode value indicates the mode of operation, he has 0,1,2,3 four modes, commonly used for 0, 12 kinds. The mode=0 indicates that load balancing (round-robin) is balanced, and both NICs work.  Mode=1 indicates that fault-tolerance (active-backup) provides redundancy, working in a way that the primary and standby means that only one NIC works by default, and the other is backed up. B. Load bonding module modprobe bonding load Bonding module
5 Mode description
A: Main Standby mode: mode = 1

650) this.width=650; "src=" Http://i.imgur.com/W107pSE.png "style=" Border:0px;height:auto; "/>

 in the main standby mode, the linux bonding implementation will change the MAC address of the two slave network port of Bond to the MAC address of Bond, while the MAC address of Bond is the MAC address of the main use slave network port after bond creation is started. When the live network port fault, bond will switch to the backup network, switching process, the upper layer of the application is not aware of the impact, because bond in the drive layer, will take over the upper application of the packet, cache and so on standby network card and then sent out through the backup network card. Of course, the premise is that the switching time is very short, otherwise the buffer will overflow, after the overflow began to drop packets.    B: Load Balancing mode: Mode = 0 

650) this.width=650; "src=" Http://i.imgur.com/f4DEmhe.png "style=" Border:0px;height:auto; "/>

  load Balancing mode, the linux bonding implementation can maintain two slave network port of the MAC address is unchanged, the MAC address of Bond is one of the network card, Bond mac address selection is based on Bond's own algorithm implementation   bond load Balancing mode, requires the switch to do configuration, yes two slave network port can be interoperable, otherwise, the packet will be very bad, basic can not be used. This is because Bond's load-balanced mode algorithm transfers packets between two ports to achieve load balancing. In this mode, two slave have a separate MAC address 

The above two methods are more commonly used, in addition to the following mode modes

mode specifies the operating modes of the bond0, and in Redhat there are 0-6 total 7 working modes, 0 and 1 are commonly used.

mode=0  says  load balancing  (round-robin) is load balanced, and both NICs work. mode=1  says  fault-tolerance  (active-backup) provides redundancy and works by the way the master   slave works, meaning that only one NIC works by default, and the other is backed up.  mode=2  represents  XOR policy  as a balancing strategy. This mode provides load balancing and fault tolerance  mode=3  representation  broadcast  as a broadcast policy. This mode provides fault tolerance  mode=4  representation  IEEE 802.3ad Dynamic link aggregation  for  IEEE  802.3ad  for   dynamic Link aggregation. This policy can be changed from the default  XOR  policy to another policy through the  xmit_hash_policy  option.  mode=5  represents  Adaptive transmit load balancing  transport load balancing for the adapter. The necessary conditions for the   mode:ethtool  support getting the rate  mode=6  representation  Adaptive load  for each  slave  The balancing  is adaptive load balancing for the adapter. This mode includes    balance-tlb  mode, plus receive load balancing for  IPV4  traffic (receive load    BALANCE, RLB), and does not require any  switch (switch) support.   bonding  can only provide link monitoring, i.e. whether the link from the host to the switch is connected. If it's just the switch's link to   out, and the switch itself is not faulty, then  bonding  will thinkLink is not a problem and continues to be used  . 
6 How to view the current bond mode
#cat/proc/net/bonding/bond0

The output looks like this:

Ethernet Channel Bonding driver:v3.6.0 (September) Bonding mode:fault-tolerance (active-backup) Primary slave:e Th4 (Primary_reselect always) currently Active slave:eth4mii status:upmii Polling Interval (ms): 300Up Delay (ms): 0Down Delay (ms): 0 Slave interface:eth6mii status:upspeed:10000 mbpsduplex:fulllink Failure count:1permanent HW addr:8c:d C:d4:12:bf:c8slave queue id:0 Slave interface:eth4mii status:upspeed:10000 mbpsduplex:fulllink Failure Count:1perman ent HW addr:8c:dc:d4:12:b0:80slave Queue id:0
7 How to configure yourself bond--mode one
step 1, edit the virtual network interface configuration file, specify the network card ip  assume that eth0 is the external service network card, has been debugging good networks; Eth1 is a NIC that wants to provide services to eth0 at the same time  # cd /etc/ sysconfig/network-scripts/  #vi  ifcfg-bond0  Write the following information and the original  ifcfg-eth0  configuration is actually similar. So I propose to execute the following statement, copy the Ifcfg-eth0 and then change it.  # cp ifcfg-eth0 ifcfg-bon0  Ifcfg-bon0 's information will be revised roughly as follows:  device=bond0bootproto= Staticipaddr=[ip]netmask=[mask]broadcast=[broadcast]gateway=[gateway]onboot=yestype=ethernet 

Step 2 Configure the Real network card

Modify the Ifcfg-eth0 as follows: Device=eth0bootproto=noneonboot=yesmaster=bond0 #如果不写, you must do the fourth step Slave=yes #如果不写, you must do the fourth step Userctl =yes

Similarly, fix ifcfg-eth1 as follows:

Device=eth1bootproto=noneonboot=yesmaster=bond0 #如果不写, you must do the fourth step Slave=yes #如果不写, you must do fourth step Userctl=yes step 3, Load module block, let the system support bonding by default, the kernel already supports bonding--simply modify/etc/modprobe.conf This configuration document: Add two lines alias bond0 bonding options Bond0 miimon= Mode=1 Step 4, add boot start script in/etc/rc.d/rc.local
Ifenslave bond0 eth0 eth1

If Eth0 and Eth1 both write master and slave, then the above steps do not matter.

7 How to configure your own bond--mode two
 step 1:create a bond device, simply follow these three  steps :   - ensure that the required drivers are  Properly loaded :     # modprobe bonding ; modprobe  <3c59x|eepro100|pcnet32|tulip|...>  step 2:assign an ip address  to the bond device :     # ifconfig bond0  <addr> netmask <mask> broadcast <bcast>  step 3:  attach all the interfaces you need to the bond device : &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;#&NBSP;IFENSLAVE&NBSP;[{-F|--FORCE}]&NBSP;BOND0&NBSP;ETH0&NBSP;[ETH1&NBSP;[ETH2] ...]  if bond0 didn ' T have a mac address, it will take eth0 ' s. then, all  &Nbsp;  interfaces attached after this assignment will get the  same MAC addr.      (Except for alb/tlb modes)
8 Linux single-NIC binding multi-IP
Mode 1, single-NIC binding multi-IP in the Redhat series implementation method if you need to bind a multi-IP network card is eth0, please create a file named ifcfg-eth0:0 in the/etc/sysconfig/network-scripts/directory

Examples of the content are:

Device= "eth0:0″ipaddr=" 192.168.0.2″broadcast= "192.168.0.255″netmask=" 255.255.255.0″onboot= "yes" where devices are the name of the device , ipaddr the IP address for this device, broadcast is the broadcast address---can omit netmask as the subnet mask, onboot indicates that it starts automatically when the system starts.  If you need to bind more than one IP address, only need to put the file name and the device in the document ETH0:X plus one after the modification of the IP information, Linux can support up to 255 IP aliases. Mode 2:ifconfig eth0:1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0 can add the above command to the startup self-running file, Linux is/etc/rc.d/ Rc.local.


Linux single-NIC binding multi-IP and bongding implementation

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.