Linux – Network Interface (NIC) Bonding Howto

Linux – Network Interface (NIC) Bonding

NIC bonding is creation of a single bonded interface by combining 2 or more ethernet interfaces. This helps in high availability and performance improvement.

I will demonstrate in this article, how you can setup Network Interface (NIC) bonding in Linux.

Linux – Network Interface (NIC) Bonding

I’ll start with a standard server with 2 NICs, eth0 and eth1 to setup Network Interface (NIC) Bonding. Here is the output from ifconfig:

[[email protected] ~]# /sbin/ifconfig

Output:

eth0      Link encap:Ethernet  HWaddr 02:06:23:9E:R1:34  
          inet addr:10.0.0.2  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:329563409 errors:0 dropped:0 overruns:0 frame:0
          TX packets:281984862 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:212207668 (202.3 Mb)  TX bytes:2094301826 (1997.2 Mb)
          Base address:0xdcc0 Memory:fcfa0000-fcfc0000 

eth1      Link encap:Ethernet  HWaddr 00:04:23:3W:Q1:57
          inet addr:10.0.0.3  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2359168 errors:0 dropped:0 overruns:0 frame:0
          TX packets:923040 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:217316501 (207.2 Mb)  TX bytes:114101861 (108.8 Mb)
          Base address:0xdc80 Memory:fcf80000-fcfa0000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16379809 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16379809 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3183866656 (3036.3 Mb)  TX bytes:3183866656 (3036.3 Mb)

The configuration scripts are found in /etc/sysconfig/network-scripts/:

-rw-r--r--    3 root     root          225 Mar 13  2013 ifcfg-eth0
-rw-r--r--    3 root     root          224 Mar 21  2011 ifcfg-eth1
-rw-r--r--    1 root     root          254 Jan 21  2011 ifcfg-lo

First we add a config file for bond0, /etc/sysconfig/network-scripts/ifcfg-bond0. The following will be content of the file:

DEVICE=bond0
IPADDR=10.0.0.2
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Now we edit /etc/sysconfig/network-scripts/ifcfg-eth0 file and make it look like something below:

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

Now we edit /etc/sysconfig/network-scripts/ifcfg-eth1 file and make it look like something given below:

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

Network scripts are now complete in /etc/sysconfig/network-scripts:

Set the parameters for bond0 bonding kernel module. Add the following lines to /etc/modprobe.conf

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

Load the bond driver module from the command prompt.

[[email protected] ~]# modprobe bonding

Restart the network

[[email protected] ~]# /etc/init.d/network restart

You should be all set now!

You can now access the box with the IP address assigned to bond0 interface.

Check for the configurations via the following commands:

[[email protected] ~]# /sbin/ifconfig

and

[[email protected] ~]# cat /proc/net/bonding/bond0

Linux – Network Interface (NIC) Bonding

No Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.