The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical “bonded” interface.
The behavior of the bonded interfaces depends upon the mode; generally speaking,  modes provide either hot standby or load balancing services.
Additionally, link integrity monitoring may be performed.

Most popular distro kernels ship with the bonding driver already available as a module and the ifenslave user level control program installed and ready for use.

Configuring Bonding Devices

Here we are Configuring Bonding  with Initscripts Support.
See also:
Linux bonding Configuration with Sysconfig Support
Configuring Bonding via Sysfs

Prerequisites :

You need two Ethernet cards installed on your node . Name it eth0 and eth1

Step1:

Create a bond network script. The file name for this script will be /etc/sysconfig/network-scripts/ifcfg-bondX where X is the number of the bond. For bond0 the file is named “ifcfg-bond0”, for bond1 it is named “ifcfg-bond1”, and so on.

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Within that file, place the following :

DEVICE=bond0
IPADDR=192.168.1.101
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_MODULE_OPTS="mode=active-backup miimon=100"

Be sure to change the networking specific lines (IPADDR, NETMASK, NETWORK and BROADCAST) to match your network configuration.
For later versions of initscripts, such as that found with Fedora 7 and Red Hat Enterprise Linux version 5 (or later), it is possible, and, indeed, preferable, to specify the bonding options in the ifcfg-bond0. Hence we added it in ifcfg-bond0 file. file, e.g. a line of the format:

BONDING_OPTS=”mode=active-backup arp_interval=60 arp_ip_target=+192.168.1.254″

will configure the bond with the specified options. The options specified in BONDING_OPTS are identical to the bonding module parameters except for the arp_ip_target field. Each target should be included as a separate option and should be preceded by a ‘+’ to indicate it should be added to the list of queried targets, e.g.,

arp_ip_target=+192.168.1.1 arp_ip_target=+192.168.1.2

See all bonding options here Bonding driver options

is the proper syntax to specify multiple targets. When specifying options via BONDING_OPTS, it is not necessary to edit /etc/modules.conf or /etc/modprobe.conf.

For older versions of initscripts that do not support BONDING_OPTS, it is necessary to edit /etc/modules.conf (or /etc/modprobe.conf, depending upon your distro) to load the bonding module with your desired options when the bond0 interface is brought up. The
following lines in /etc/modules.conf (or modprobe.conf) will load the bonding module, and select its options:

alias bond0 bonding
options bond0 mode=balance-alb miimon=100

Replace the sample parameters with the appropriate set of options for your configuration.

Step2 :
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

With in ifcfg-eth0 file place following :

DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Step3:
# vi /etc/modprobe.d/bonding.conf

Edit or add bonding.conf file and add following content to it and save file

alias bond0 bonding
Step4:

Finally run “/etc/init.d/network restart” as root. This will restart the networking subsystem and your bond link should be now up and running.

# service network restart

After successful configuration you will able to see something like this :

Querying Bonding Configuration:

Network configuration

The network configuration can be inspected using the ifconfig command. Bonding devices will have the MASTER flag set; Bonding slave devices will have the SLAVE flag set. The ifconfig output does not contain information on which slaves are associated with which masters.

In the example below, the bond0 interface is the master (MASTER) while eth0 and eth1 are slaves (SLAVE). Notice all slaves of bond0 have the same MAC address (HWaddr) as bond0 for all modes except TLB and ALB that require a unique MAC address for each slave.

# ifconfig
bond0  Link encap:Ethernet HWaddr 00:50:56:22:43:48 
 inet addr:10.192.8.171 Bcast:10.192.8.255 Mask:255.255.255.0
 inet6 addr: fe80::250:56ff:fe22:4348/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
 RX packets:5224 errors:0 dropped:0 overruns:0 frame:0
 TX packets:391 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0 
 RX bytes:383617 (374.6 KiB) TX bytes:113548 (110.8 KiB)

eth0  Link encap:Ethernet HWaddr 00:50:56:22:43:48 
 inet6 addr: fe80::250:56ff:fe22:4348/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
 RX packets:2876 errors:0 dropped:0 overruns:0 frame:0
 TX packets:196 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000 
 RX bytes:221392 (216.2 KiB) TX bytes:48104 (46.9 KiB)

eth1  Link encap:Ethernet HWaddr 00:50:56:22:43:48 
 inet6 addr: fe80::250:56ff:fe22:4348/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
 RX packets:2349 errors:0 dropped:0 overruns:0 frame:0
 TX packets:196 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000 
 RX bytes:162291 (158.4 KiB) TX bytes:65558 (64.0 KiB)

lo  Link encap:Local Loopback 
 inet addr:127.0.0.1 Mask:255.0.0.0
 inet6 addr: ::1/128 Scope:Host
 UP LOOPBACK RUNNING MTU:65536 Metric:1
 RX packets:493 errors:0 dropped:0 overruns:0 frame:0
 TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0 
 RX bytes:178235 (174.0 KiB) TX bytes:178235 (174.0 KiB)

How to check bonding status:

Each bonding device has a read-only file residing in the /proc/net/bonding directory. The file contents include information about the bonding configuration, options and state of each slave.

cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
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:50:56:22:43:48
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:20:75:d6
Slave queue ID: 0

How to check all existing bonds:

# cat /sys/class/net/bonding_masters
bond0

Configuring Bonding  Using DHCP

Recent versions of initscripts (the versions supplied with Fedora
Core 3 and Red Hat Enterprise Linux 4, or later versions, are reported to
work) have support for assigning IP information to bonding devices via
DHCP.

To configure bonding for DHCP, configure it as described above, except replace the line “BOOTPROTO=none” with “BOOTPROTO=dhcp” and add a line consisting of “TYPE=Bonding”. Note that the TYPE value is case sensitive.

 

How to Configure Multiple Bonds Manually

This section contains information on configuring multiple bonding devices with differing options for those systems whose network initialization scripts lack support for configuring multiple bonds.

If you require multiple bonding devices, but all with the same options, you may wish to use the “max_bonds” module parameter, documented above.

To create multiple bonding devices with differing options, it is preferrable to use bonding parameters exported by sysfs, documented in the section below.

For versions of bonding without sysfs support, the only means to provide multiple instances of bonding with differing options is to load the bonding driver multiple times. Note that current versions of the sysconfig network initialization scripts handle this automatically; if your distro uses these scripts, no special action is needed. See the
section Configuring Bonding Devices, above, if you’re not sure about your network initialization scripts.

To load multiple instances of the module, it is necessary to specify a different name for each instance (the module loading system requires that every loaded module, even multiple instances of the same module, have a unique name). This is accomplished by supplying multiple sets of bonding options in /etc/modprobe.conf, for example:

alias bond0 bonding
options bond0 -o bond0 mode=balance-rr miimon=100
alias bond1 bonding
options bond1 -o bond1 mode=balance-alb miimon=50

will load the bonding module two times. The first instance is named “bond0” and creates the bond0 device in balance-rr mode with an miimon of 100. The second instance is named “bond1” and creates the bond1 device in balance-alb mode with an miimon of 50.

In some circumstances (typically with older distributions), the above does not work, and the second bonding instance never sees its options. In that case, the second options line can be substituted as follows:

install bond1 /sbin/modprobe --ignore-install bonding -o bond1 
 mode=balance-alb miimon=50

This may be repeated any number of times, specifying a new and unique name in place of bond1 for each subsequent instance.

It has been observed that some Red Hat supplied kernels are unable to rename modules at load time (the “-o bond1” part). Attempts to pass that option to modprobe will produce an “Operation not permitted” error. This has been reported on some Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels exhibiting this problem, it will be impossible
to configure multiple bonds with differing parameters (as they are older kernels, and also lack sysfs support).

How to change  MAC address of Bond

If you wish to change the MAC address, you can set it with ifconfig or ip link:

# ifconfig bond0 hw ether 00:11:22:33:44:55
# ip link set bond0 address 66:77:88:99:aa:bb

The MAC address can be also changed by bringing down/up the device and then changing its slaves (or their order):

# ifconfig bond0 down ; modprobe -r bonding
# ifconfig bond0 up
# ifenslave bond0 eth...

This method will automatically take the address from the next slave that is added.

To restore your slaves’ MAC addresses, you need to detach them from the bond
(`ifenslave -d bond0 eth0′). The bonding driver will then restore the MAC addresses that the slaves had before they were enslaved.

For detailed bonding options please refer :  Linux Bonding Options

See also : Configuring Linux Bonding for High Availability

See Also : Linux bonding via sysfs

See also : Linux Bonding other configuration options

Free Web Hosting