Did You Know?
Got a tip? Let us know

HostGator Diwali Mega Offer 50% Flat Discount on all Hosting Plans - Grab it Now

Create NIC Channel Bonding in RedHat/CentOS/Fedora

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators
CW

Channel Bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy. This is a great way of achieving redundancy to a server. If one physical NIC is down or unplugged, it will automatically move resource to other NIC card. Channel bonding will work with the help of bonding driver in kernel. This post guides you through how to create NIC / Channel Bonding in RedHat, CentOS and Fedora Linux.

Create Channel Bonding in Linux

Create Channel Bonding in Linux

How to Create NIC Channel Bonding in RedHat, CentOS and Fedora

Step 1: Creating Bonding Channel

As a root, create a new file name bonding.conf in the /etc/modprobe.d/ directory. Name can be anything you like as long as it ends with a .conf extension. Insert the following line in this new file.

alias bond0 bonding

For each configured channel bonding interface, there must be a corresponding entry in your new /etc/modprobe.d/bonding.conf file.

Step 2: Creating Channle Bonding Interface

To create a channel bonding interface, create a file in the /etc/sysconfig/network-scripts/ directory called ifcfg-bond0. The following is a sample channel bonding configuration file. (Note : IP Address may differ in your environment.)

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.8
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

Step 3: Configuring Channel Bonding Interface

After the channel bonding interface is created, the network interfaces to be bound together must be configured by adding the MASTER and SLAVE directives to their configuration files. The configuration files for each of the channel-bonded interfaces can be nearly identical. For example, if two Ethernet interfaces are being channel bonded, both eth0 and eth1 may look like the following example. Edit physical interface card details as under.

For eth0

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

For eth1

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

The above directives are self explanatory for many system admin, however, let me explain to newbie.

  1. DEVICE: Indicates what is the device name
  2. USERCTL: Indicates that can user control this device(here its no)
  3. ONBOOT:  Indicates that at the boot time do this device should be up?
  4. MASTER: Is this device has master? Then what it is(here its bond0)
  5. SLAVE: Is this device acting as slave?
  6. BOOTPROTO: What about getting IP Address from DHCP? It’s set to none which indicate it’s a static IP)

Step 4: Restarting Network Service

Restart the network service and see the output of ifconfig.

# service network restart
[root@tecmint network-scripts]# ifconfig

bond0     Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          inet addr:192.168.1.8  Bcast:172.16.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe69:31c4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
          RX packets:19676 errors:0 dropped:0 overruns:0 frame:0
          TX packets:342 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1623240 (1.5 MiB)  TX bytes:42250 (41.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:10057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:832257 (812.7 KiB)  TX bytes:22751 (22.2 KiB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:9620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:791043 (772.5 KiB)  TX bytes:20207 (19.7 KiB)
          Interrupt:19 Base address:0x2080

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:104 (104.0 b)  TX bytes:104 (104.0 b)
He has over 10 years of rich IT experience which includes various Linux Distros, FOSS and Networking. Narad always believes sharing IT knowledge with others and adopts new technology with ease.

Linux Services & Free WordPress Setup

Our post is simply ‘DIY’ aka ‘Do It Yourself, still you may find difficulties and want us to help you out. We offer wide range of Linux and Web Hosting Solutions at fair minimum rates. Please submit your orders by Clicking Here.

16 Responses

  1. Bob Styma says:

    Excellent how to. However, the ifcfg-bond0 needs the line defining the default gateway.
    as in:
    GATEWAY=192.168.1.1
    Otherwise you will not be able to get off that subnet.

  2. Dave Hostetler says:

    I’ve set up channel bonding following these steps on CentOS 6.3 bonding eth1 and eth2. The device seems to bond okay, but once bonded, the network traffic just stops. No ping, no nothing. Any clues?

    These are both ports on a Syba dual port gigabit adapter (Realtek chipset).

  3. Joe says:

    I am running Oracle Linux 5.7 (Red Hat based) and have configured bonding. I can activate the bond manually once the host is up but the bonded interfaces do not exist on reboot and the bond fails. Any ideas?

  4. joe says:

    I had the hwaddr commented out for each interface in the bond. Once I removed the comment and updated the driver it worked. Lesson learned.

  5. Parmod says:

    Please also mention mode of bonding.

  6. Bob Dobalina says:

    Sorry but shouldnt the entry for eth1 read “/etc/sysconfig/network-scripts/ifcfg-eth1″? (above it reads “eth0″). Could confuse some people. ;)

  7. Surendra says:

    Hi All,

    Can anyone tell me how to manually test the failover without bringing down the master interfaces

    • Matt says:

      ifenslave -c bond0 eth1

      this will change the active slave to eth1 without bringing down the master. if eth1 is of couse configured as the second slave.

      or to manually failover

      sudo ifconfig eth0 down
      the bond will failover to eth1
      sudo ifconfig eth0 up

      sudo ifconfig eth1 down
      the bond will fail back over to eth0
      sudo ifconfig eth1 up

  8. chris says:

    Hi,

    That’s Excellent.
    But for above NIC bonding could you please put the details of eth0 and eth1 before bonding.

    Novice to the Linux world and ether channel bonding!!

    Thanks

  9. ED Fochler says:

    networkmanager is running, and I create my bond at boot in /etc/rc.local
    If the secondary slave is marked for DHCP, it will spontaneously leave your bond0 interface. Check the mac addresses of your slaves with ifconfig, if they don’t match, there’s a problem.

    Killing networkmanager may also work. Seriously RedHat, straighten out your networking stack.

  10. Chris Burgess says:

    Network Manager in my experience needs to be off.

    Flag is NM_CONTROLLED=”no” on each interface

    Another useful flag in Bonding is selecting which interface is going to be the primary. This is useful if you have two switches and you want to have preference which switch the traffic goes over.

    BONDING_OPTS=”mode=1 miimon=100 primary=em1″

    primary=em1 means that it will always have em1 interface (Sorry Dell Server, EM1 is also considered eth0) if you lose this link which I have tested by pulling the cable. You lose two pings and em2 or eth1 whichever you are using takes over the load. When you plug the cable back in it will drop 2 pings and switch back to EM1 or eth0

Leave a Reply

This work is licensed under a (cc) BY-NC | TecMint uses cookies. By using our services, you comply to use of our cookies. More info: Privacy Policy.
© 2012-2014 All Rights Reserved.