<

Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

Set up bonding in linux for NIC redundancy

Published on
10,986 Points
4,786 Views
2 Endorsements
Last Modified:
Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator can ensure their machine will continue to be accessible in the event of a NIC failure, cable disconnection or other issue with one of the NICs.

If you run Linux servers, you can configure your Operating System to use multiple NICs in a team using the procedure below.

1. Create a bond0 configuration file


Red Hat Linux stores network configuration in the /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.1.11
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Open in new window


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

2. Modify eth0 and eth1 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 in new window


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

Open in new window


Save file and exit to shell prompt.

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

Open in new window


Save file and exit to shell prompt.

4. Test configuration


First, load the bonding module:

# modprobe bonding

Restart networking service in order to bring up bond0 interface:

# service network restart

List all interfaces:

# ifconfig

Output:

bond0 Link encap:Ethernet HWaddr 00:0C:29:82:0F:46
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe82:f46/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2313 errors:0 dropped:0 overruns:0 frame:0
TX packets:2372 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1591448 (1.5 MiB) TX bytes:806958 (788.0 KiB)

eth0 Link encap:Ethernet HWaddr 00:0C:29:82:0F:46
inet6 addr: fe80::20c:29ff:fe82:f46/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:2187 errors:0 dropped:0 overruns:0 frame:0
TX packets:1826 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1564864 (1.4 MiB) TX bytes:583939 (570.2 KiB)
Interrupt:185 Base address:0×1400

eth1 Link encap:Ethernet HWaddr 00:0C:29:82:0F:46
inet6 addr: fe80::20c:29ff:fe82:f46/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:126 errors:0 dropped:0 overruns:0 frame:0
TX packets:546 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26584 (25.9 KiB) TX bytes:223019 (217.7 KiB)
Interrupt:169 Base address:0×1480

Open in new window

As you can see, we now have one ip for both NICs in the form of bond0. If u want to test this method and ensure it will work when a NIC fails or is disconnected, simply use this command to shutdown one NIC - simulating a NIC failure.

#ifconfig eth1 down

Then, ping the IP given to the bond. You should receive a reply to your ping even after shutting down the second NIC. This is what redundancy is all about!
2
Comment
Author:acl-puzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Author Comment

by:acl-puzz
"I did find another site - other than your blog - which has content similar to that of your article here. It is at http://wiki.openvz.org/Bonding. Could you please confirm that is also your site? "

lol this not my site and i never ever went to that cant prove that though!!

do whatever you think appropriate.........  enough said!
0
 

Expert Comment

by:yellowteam
Hi Cheers! for the great set up guide, would you be able to tell me where I put the gateway for the bond?
Do I just add it to the bond0 config file as GATEWAY=xxx.xxx.xxx.xxx?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month