Tuesday, March 29, 2011

Bonding

Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding.

Here are the steps to configure Bonding :


Step #1: Create a bond0 configuration file
 Red Hat Linux stores network configuration in /etc/sysconfig/network-scripts/ directory. First, you need to create bond0 config file:

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

Append following lines to it:DEVICE=bond0 
 IPADDR=192.168.10.5 
 NETWORK=192.168.10.0 
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes


# vi /etc/sysconfig/network-scripts/ifcfg-bond1
Append following lines to it:DEVICE=bond0 
 IPADDR=192.168.0.5 
 NETWORK=192.168.0.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes


Replace above IP address with your actual IP address. Save file and exit to shell prompt. 

 Step #2: Modify eth0, eth1, eth2 and eth3 config files: 

 Open both configuration using vi text editor and make sure file read as follows for eth0 interface

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

Modify/append directive as follows:DEVICE=eth0 

USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


Open eth1 configuration file using vi text editor:


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


Make sure file read as follows for eth1 interface:


DEVICE=eth1 
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none



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


Make sure file read as follows for eth2 interface:


DEVICE=eth2
USERCTL=no
ONBOOT=yes
 MASTER=bond1 
SLAVE=yes
BOOTPROTO=none



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


Make sure file read as follows for eth3 interface:


DEVICE=eth3
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none



Save file and exit to shell prompt. 


Step # 3: Load bond driver/module
Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:


# vi /etc/modprobe.conf


Append following two lines:


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


Save file and exit to shell prompt. You can learn more about all bounding options in kernel source documentation file (click here to read file online). 


Step # 4: Test configuration
First, load the bonding module:


# modprobe bonding


Restart networking service in order to bring up bond0 interface


:# service network restart


Verify everything is working


:# less /proc/net/bonding/bond0Output:  


Bonding FAQ

How many bonding devices can I have?


One for each module you load. See section on module parameters for how
to accomplish this.


How many slaves can a bonding device have?


Limited by the number of network interfaces Linux supports and the
number of cards you can place in your system.


Where does a bonding device get its MAC address from?


If not explicitly configured with ifconfig, the MAC address of the
bonding device is taken from its first slave device. This MAC address
is then passed to all following slaves and remains persistent (even if
the the first slave is removed) until the bonding device is brought
down or reconfigured.


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


# ifconfig bond0 ha ether 00:11:22:33:44:55


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 will be added.


To restore your slaves' MAC addresses, you need to detach them
from the bond (`ifenslave -d bond0 eth0'), set them down
(`ifconfig eth0 down'), unload the drivers (`rmmod 3c59x', for
example) and reload them to get the MAC addresses from their
eeproms. If the driver is shared by several devices, you need
to turn them all down. Another solution is to look for the MAC
address at boot time (dmesg or tail /var/log/messages) and to
reset it by hand with ifconfig :


# ifconfig eth0 down
# ifconfig eth0 hw ether 00:20:40:60:80:A0


Note that this document comes without warranty of any kind. But every effort has been made to provide the information as accurate as possible. I welcome emails from any readers with comments, suggestions, and corrections at webmaster_at admin@linuxhowto.in

Copyright © 2012 LINUXHOWTO.IN

1 comment:

  1. Guarantee - The gathering that gives the Surety Bond ensuring the commitment covered under the bond will be performed. (Eg. The guaranteeing insurance agency)
    power MOSFET

    ReplyDelete