{"id":648,"date":"2012-07-10T16:52:24","date_gmt":"2012-07-10T08:52:24","guid":{"rendered":"http:\/\/rmohan.com\/?p=648"},"modified":"2012-07-11T11:12:07","modified_gmt":"2012-07-11T03:12:07","slug":"ethernet-bonding-in-linux","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=648","title":{"rendered":"Ethernet bonding in Linux"},"content":{"rendered":"<p>Bonding is creation of a single bonded interface by combining 2 or more ethernet interfaces. This helps in high availability and performance improvement.<\/p>\n<p>Steps for bonding in Fedora Core and Redhat Linux<\/p>\n<p>Step 1.<\/p>\n<p>Create the file ifcfg-bond0 with the IP address, netmask and gateway. Shown below is my test bonding config file.<\/p>\n<p>$ cat \/etc\/sysconfig\/network-scripts\/ifcfg-bond0<\/p>\n<p>DEVICE=bond0<br \/>\nIPADDR=192.168. 10.100<br \/>\nNETMASK=255. 255.255.0<br \/>\nGATEWAY=192. 168.10.1<br \/>\nUSERCTL=no<br \/>\nBOOTPROTO=none<br \/>\nONBOOT=yes<\/p>\n<p>Step 2.<\/p>\n<p>Modify eth0, eth1 and eth2 configuration as shown below. Comment out, or remove the ip address, netmask, gateway and hardware address from each one of these files, since settings should only come from the ifcfg-bond0 file above.<\/p>\n<p>$ cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/p>\n<p>DEVICE=eth0<br \/>\nBOOTPROTO=none<br \/>\nONBOOT=yes<br \/>\nMASTER=bond0<br \/>\nSLAVE=yes<\/p>\n<p>$ cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth1<\/p>\n<p>DEVICE=eth1<br \/>\nBOOTPROTO=none<br \/>\nONBOOT=yes<br \/>\nUSERCTL=no<br \/>\nMASTER=bond0<br \/>\nSLAVE=yes<\/p>\n<p>$ cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth2<\/p>\n<p>DEVICE=eth2<br \/>\nBOOTPROTO=none<br \/>\nONBOOT=yes<br \/>\nMASTER=bond0<br \/>\nSLAVE=yes<\/p>\n<p>Step 3.<\/p>\n<p>Set the parameters for bond0 bonding kernel module. Add the following lines to \/etc\/modprobe. conf<\/p>\n<p># bonding commands<br \/>\nalias bond0 bonding<br \/>\noptions bond0 mode=balance-alb miimon=100<\/p>\n<p>Note: Here we configured the bonding mode as &#8220;balance-alb&#8221;. All the available modes are given at the end and you should choose appropriate mode specific to your requirement.<\/p>\n<p>Step 4.<\/p>\n<p>Load the bond driver module from the command prompt.<\/p>\n<p>$ modprobe bonding<\/p>\n<p>Step 5.<\/p>\n<p>Restart the network, or restart the computer.<\/p>\n<p>$ service network restart # Or restart computer<\/p>\n<p>When the machine boots up check the proc settings.<\/p>\n<p>$ cat \/proc\/net\/bonding\/bond0<br \/>\nEthernet Channel Bonding Driver: v3.0.2 (March 23, 2006)<\/p>\n<p>Bonding Mode: adaptive load balancing<br \/>\nPrimary Slave: None<br \/>\nCurrently Active Slave: eth2<br \/>\nMII Status: up<br \/>\nMII Polling Interval (ms): 100<br \/>\nUp Delay (ms): 0<br \/>\nDown Delay (ms): 0<\/p>\n<p>Slave Interface: eth2<br \/>\nMII Status: up<br \/>\nLink Failure Count: 0<br \/>\nPermanent HW addr: 00:13:72:80: 62:f0<\/p>\n<p>Look at ifconfig -a and check that your bond0 interface is active. You are done!<\/p>\n<p>RHEL bonding supports 7 possible &#8220;modes&#8221; for bonded interfaces. These modes determine the way in which traffic sent out of the bonded interface is actually dispersed over the real interfaces. Modes 0, 1, and 2 are by far the most commonly used among them.<\/p>\n<p>* Mode 0 (balance-rr)<br \/>\nThis mode transmits packets in a sequential order from the first available slave through the last. If two real interfaces are slaves in the bond and two packets arrive destined out of the bonded interface the first will be transmitted on the first slave and the second frame will be transmitted on the second slave. The third packet will be sent on the first and so on. This provides load balancing and fault tolerance.<\/p>\n<p>* Mode 1 (active-backup)<br \/>\nThis mode places one of the interfaces into a backup state and will only make it active if the link is lost by the active interface. Only one slave in the bond is active at an instance of time. A different slave becomes active only when the active slave fails. This mode provides fault tolerance.<\/p>\n<p>* Mode 2 (balance-xor)<br \/>\nTransmits based on XOR formula. (Source MAC address is XOR&#8217;d with destination MAC address) modula slave count. This selects the same slave for each destination MAC address and provides load balancing and fault tolerance.<\/p>\n<p>* Mode 3 (broadcast)<br \/>\nThis mode transmits everything on all slave interfaces. This mode is least used (only for specific purpose) and provides only fault tolerance.<\/p>\n<p>* Mode 4 (802.3ad)<br \/>\nThis mode is known as Dynamic Link Aggregation mode. It creates aggregation groups that share the same speed and duplex settings. This mode requires a switch that supports IEEE 802.3ad Dynamic link.<\/p>\n<p>* Mode 5 (balance-tlb)<br \/>\nThis is called as Adaptive transmit load balancing. The outgoing traffic is distributed according to the current load and queue on each slave interface. Incoming traffic is received by the current slave.<\/p>\n<p>* Mode 6 (balance-alb)<br \/>\nThis is Adaptive load balancing mode. This includes balance-tlb + receive load balancing (rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the server on their way out and overwrites the src hw address with the unique hw address of one of the slaves in the bond such that different clients use different hw addresses for the server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bonding is creation of a single bonded interface by combining 2 or more ethernet interfaces. This helps in high availability and performance improvement.<\/p>\n<p>Steps for bonding in Fedora Core and Redhat Linux<\/p>\n<p>Step 1.<\/p>\n<p>Create the file ifcfg-bond0 with the IP address, netmask and gateway. Shown below is my test bonding config file.<\/p>\n<p>$ cat [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/648"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=648"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions\/679"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}