Linux NIC bonding

Linux Network Interface Card (NIC) bonding aggregates multiple network interface into one unit. It supports load balance and failure redundancy.  In this demo we have 2 network interfaces eth0 and eth1 and we want to bond them into one interface bond0.

1) As root user edit bonding interface configuration file

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

Add the following lines into it:

DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

2) Edit bonding slave interface configuration for eth0 and eth1

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

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

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

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

4) Test connection

load the bonding module
$> modprobe bonding

If you have not loaded the module, when bringing up bond0 network you will meet this error:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bringing up interface bond0:  Device bond0 does not seem to be present, delaying initialization.
[FAILED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

restart network service in order to bring up bond0
$> service network restart

check the result
$> less /proc/net/bonding/bond0
$> ifconfig

bond0     Link encap:Ethernet  HWaddr 08:00:27:76:3C:AB
inet addr:10.10.10.102  Bcast:10.10.10.255  Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe76:3cab/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
RX packets:98 errors:0 dropped:0 overruns:0 frame:0
TX packets:126 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16834 (16.4 KiB)  TX bytes:18598 (18.1 KiB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:76:3C:AB
UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7818 (7.6 KiB)  TX bytes:9970 (9.7 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:76:3C:AB
UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
RX packets:50 errors:0 dropped:0 overruns:0 frame:0
TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9016 (8.8 KiB)  TX bytes:8628 (8.4 KiB)

Advertisements
Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: