Ethernet Channel Bonding aka NIC Teaming on Linux Systems

Ethernet Channel Bonding enables two or more Network Interfaces Card (NIC) to a single virtual NIC card which may increase the bandwidth and provides redundancy of NIC Cards. This is a great way to achieve redundant links, fault tolerance or load balancing networks in production system. If one physical NIC is down or unplugged, it will automatically move resources to other NIC card. Channel/NIC bonding will work with the help of bonding driver in Kernel. We’ll be using two NIC to demonstrate the same.

Ethernet Channel Bonding
Ethernet Channel Bonding

There are almost six types of Channel Bond types are available. Here, we’ll review only two type of Channel Bond which are popular and widely used.

  1. 0: Load balancing (Round-Robin) : Traffic is transmitted in sequential order or round-robin fashion from both NIC. This mode provides load balancing and fault tolerance.
  2. 1: Active-Backup : Only one slave NIC is active at any given point of time. Other Interface Card will be active only if the active slave NIC fails.

Creating Ethernet Channel Bonding

We have two Network Ethernet Cards i.e eth1 and eth2 where bond0 will be created for bonding purpose. Need superuser privileged to execute below commands.

Load Balancing (Round-Robin)

Configure eth1

Mention parameter MASTER bond0 and eth1 interface as a SLAVE in config file as shown below.

# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
TYPE=Ethernet
ONBOOT="yes"
BOOTPROTO="none"
USERCTL=no
MASTER=bond0
SLAVE=yes
Configure eth2

Here also, specify parameter MASTER bond0 and eth2 interface as a SLAVE.

# vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE="eth2"
TYPE="Ethernet"
ONBOOT="yes"
USERCTL=no
#NM_CONTROLLED=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
Create bond0 Configuration

Create bond0 and configure Channel bonding interface in the “/etc/sysconfig/network-scripts/” directory called ifcfg-bond0.

The following is a sample channel bonding configuration file.

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.246.130
NETMASK=255.255.255.0
BONDING_OPTS="mode=0 miimon=100"

Note: In the above configuration we have chosen Bonding Options mode=0 i.e Round-Robin and miimon=100 (Polling intervals 100 ms).

Let’s see interfaces created using ifconfig command which shows “bond0” running as the MASTER both interfaces “eth1” and “eth2” running as SLAVES.

# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0C:29:57:61:8E
          inet addr:192.168.246.130  Bcast:192.168.246.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe57:618e/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:17374 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16060 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1231555 (1.1 MiB)  TX bytes:1622391 (1.5 MiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:57:61:8E
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:16989 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8072 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1196931 (1.1 MiB)  TX bytes:819042 (799.8 KiB)
          Interrupt:19 Base address:0x2000

eth2      Link encap:Ethernet  HWaddr 00:0C:29:57:61:8E
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7989 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:34624 (33.8 KiB)  TX bytes:803583 (784.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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

Restart Network service and interfaces should be OK.

# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:                               [  OK  ]

Checking the status of the bond.

# watch -n .1 cat /proc/net/bonding/bond0
Sample Ouput

Below output shows that Bonding Mode is Load Balancing (RR) and eth1 & eth2 are showing up.

Every 0.1s: cat /proc/net/bonding/bond0                         Thu Sep 12 14:08:47 2013 

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: 00:0c:29:57:61:8e
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: 00:0c:29:57:61:98
Slave queue ID: 0

Create Active Backup

In this scenario, Slave interfaces remain same. only one change will be there in the bond interface ifcfg-bond0 instead of ‘0‘ it will be ‘1‘ which is shown as under.

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.246.130
NETMASK=255.255.255.0
BONDING_OPTS="mode=1 miimon=100"

Restart network service and check the status of bonding.

# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:                               [  OK  ]

Checking the status of the bond with command.

# watch -n .1 cat /proc/net/bonding/bond0
Sample Output

Bonding Mode is showing fault-tolerance (active-backup) and Slave Interface is up.

Every 0.1s: cat /proc/n...  Thu Sep 12 14:40:37 2013

Ethernet Channel Bonding Driver: v3.6.0 (September 2
6, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:0c:29:57:61:8e
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:0c:29:57:61:98
Slave queue ID: 0

Note: Manually down and up the Slave Interfaces to check the working of Channel Bonding. Please see the command as below.

# ifconfig eth1 down
# ifconfig eth1 up

Thats it!

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Narad Shrestha
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.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

15 Comments

Leave a Reply
  1. Hello, I am novice to Linux . Have a question about the configuration related to teaming. I have understood the configuration shown on this page . Just have a confusion related to the Master connection . The Bond0(Master) connection ip was given 192.168.246.130 . So which ip is given to BOND0 . Is it the machine’s(Server) IP on which the teaming is configured, Or how to get the IP to put in BOND0

    Reply
  2. We have bonding setup as active/standby and our nics are going to 2 separate switches with a vlan going between the 2. We keep seeing the switches switch back and forth on who learn the mac-address for the linux server. When it learns the backup nic the linux server no longer pings.

    Is there an option we have set that is causing this behavior or a setting we need to set to stop this behavior?

    r-osasumn2-2#sh mac-address-table address 0202.9905.0301
    Legend: * – primary entry
    age – seconds since last seen
    n/a – not available

    vlan mac address type learn age ports
    ——+—————-+——–+—–+———-+————————–
    Module 1:
    * 503 0202.9905.0301 dynamic Yes 10 Po10
    Module 3:
    * 503 0202.9905.0301 dynamic Yes 250 Po10

    r-osasumn2-1#sh mac-address-table address 0202.9905.0301
    Legend: * – primary entry
    age – seconds since last seen
    n/a – not available

    vlan mac address type learn age ports
    ——+—————-+——–+—–+———-+————————–
    Module 1:
    * 503 0202.9905.0301 dynamic Yes 45 Te1/2

    I wouldn’t think the backup nic would try sending an arp annouce since it the backup and shouldn’t be in use.

    Reply
    • you could try using mode2

      mode=2 (balance-xor)
      XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

      Reply
  3. Hello Abhishek,

    To remove bonding:

    ifconfig bond0 down

    rmmod bonding

    rmmod tg3

    ifconfig ethX up or ifconfig ethX “IP.ADD.RE.S” or

    then reconfigure your /etc/sysconfig/network-scripts/ifcfg-ethX

    NB. X corresponds to 0,1,2 like eth0, eth1.. etc…

    Reply
  4. Hi,

    nice article. Please add also information that this standard is called 802.3ad and you need to have a switch that supports this standard.

    thanks,
    Jindrich

    Reply
  5. “/etc/sysconfig/network-scripts/ifcfg-eth1”
    “/etc/sysconfig/network-scripts/ifcfg-eth1” E212: Can’t open file for writing
    Press ENTER or type command to continue

    This is the error I am getting. I am logged in as “root” user. Using Ubuntu 13.10.

    Reply
  6. Will ethernet channel bonding work if both NIC’s (eth1 and eth2) are of different speeds

    i.e eth1 full duplex and eth2 half duplex

    Does it depend upon the make and model of the NIC’s to work on with channel bonding.

    Reply
  7. Hi Sir,

    Will ethernet channel bonding work if both NIC’s (eth1 and eth2) are of different speeds

    i.e eth1 full duplex and eth2 half duplex

    Does it depend upon the make and model of the NIC’s to work on with channel bonding.

    Regards,
    Phani

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.