<

Set up bonding in linux for NIC redundancy

Published on
11,514 Points
5,314 Views
2 Endorsements
Last Modified:
Approved
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
Author:acl-puzz
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free