How to Set up Network Bonding in Ubuntu 6.10

Want to support HowtoForge? Become a subscriber!
 
Submitted by stutch (Contact Author) (Forums) on Tue, 2007-02-13 18:48. :: Ubuntu | Networking

How to Set up Network Bonding in Ubuntu 6.10 

Why you may want to do this:

Network Bonding, otherwise known as port trunking allows you to combine multiple network ports into a single group, effectively aggregating the bandwidth of multiple interfaces into a single connection. For example, you can aggregate two gigabyte ports into a two-gigabyte trunk port. Bonding is used primarily to provide network load balancing and fault tolerance. First, we will run two different network tools to check for network connectivity and capability. Run mii-tool to check your interfaces for connectivity:

mii-tool

For our purposes, we will assume you have three interfaces. The result of the mii-tool command is listed below:

eth0: negotiated 100baseTx-HD, link ok
eth1: negotiated 100baseTx-HD, link ok
eth2: negotiated 100baseTx-HD, link ok

Next run ethtool for each interface to check to see what capabilities:

ethtool eth0 && ethtool eth1 && ethtool eth3

The result of the ethtool command is listed below:

Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Half
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: yes
Settings for eth1:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: Unknown! (65535)
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
        Link detected: no
Settings for eth3:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: Unknown! (65535)
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
        Link detected: no

Next, we need to install ifenslave. It’s a simple install:

apt-get update && apt-get install ifenslave

Options for mode types:

You can set up your bond interface according to your needs. In order to do this, you simply change the mode type depicted in the examples below (mode=X). There are seven mode types available. They are as follows:

mode=0

This mode uses the Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1

This mode uses an Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2

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.

mode=3

Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4

IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

          *Pre-requisites:

1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.

2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require    some type of configuration to enable 802.3ad mode

mode=5

Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

*Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.

mode=6

Adaptive load balancing: includes balance-transmit load balancing plus receive load balancing for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

Now append the following items to your aliases file:

pico /etc/modprob.d/aliases

# Append to the bottom of this file:
alias bond0 bonding
alias eth0 e100
alias eth1 e100
alias eth2 e100
options bonding mode=0 miimon=100

Next, append the following items to your i386 file:

pico /etc/modprob.d/arch/i386

# Append to the bottom of this file:
alias bond0 bonding
options bonding mode=0 miimon=100 downdelay=200 updelay=200

Now we have to modify the interface file. Start off by commenting out any information on the physical interfaces, eth0, eth1, etc, and create a virtual interface such as bond0, configure it similar to below, and be sure to choose a unique hwaddress. Be sure to leave the loopback interface configuration intact.

pico /etc/network/interfaces

It should look something like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto eth0
#iface eth0 inet static
#   address 192.168.0.120
#   netmask 255.255.255.0
#   network 192.168.0.0
#   broadcast 192.168.0.255
#   gateway 192.168.0.1
auto bond0
iface bond0 inet static
   address 192.168.0.120
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255
   gateway 192.168.0.1
   hwaddress ether 00:03:B3:48:50:2C
   post-up ifenslave bond0 eth0 eth1

Save the file and then reboot the system:

shutdown -r now


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Rokabear Tech S... (not registered) on Thu, 2011-04-14 16:48.

We have had really good luck with intel cards on Mode 1, but any of the other modes have gone flaky after heavy use for a few months.  Nothing to terrible, but you have to reboot the box. It has only really been a concern for our VPS hosting boxes, but once we switched everything to mode 1 we haven't had any problems. If you do not mind rebooting every once in a while, it seems to not be a problem. Some of our dedicated server hosting customers have reported really good luck with Mode 2. I think our VPS hosts probably see alot of diverse traffic and maybe that is the crux of the issue. Either way we use it on all of our boxes and it works great!

 

Rokabear Tech Support


 

Submitted by Anonymous (not registered) on Mon, 2009-02-23 16:00.

Thanks, worked a treat.

Though, eth0 & eth1 returned errors on my Sun X4100 so I had to use eth2 & eth3.

Submitted by Djolliff (registered user) on Mon, 2007-03-26 03:54.

This doesn't work on Kubuntu 6.10 with RealTek (module r8169) cards.

mode=0 works sometimes - and this may be problematic because I have two dumb switches cascaded, however any other applicable mode (mode=6 for example) will not even initialize the interface.  Any attempts to manipulate the interface after that causes a partial system lock up. 

mii-tool doesn't work with those cards either, however, ethtool presents the same output as described.

 

Any feed back on this would be appreciated, and I'll be testing mode=0 on a single switch in the next week.


 

 

Submitted by stutch (registered user) on Tue, 2007-04-24 14:22.

Sorry for the long delay in responding!  I am not familiar with Realtek network cards, however if mii-tool doesn't work for the network cards that you are using, that usually means that the NICs you are using do not support bonding functionality. 

Do you have any other NICs that you can through in there to get up and running?

Submitted by Julian (not registered) on Wed, 2010-08-18 12:44.
Thank you for such info.
I have two adsl lines, with static IP.
Is the Network Bonding applicable im my case? As I see on your post, it's possible.
Should I ask my ISP's for special protocols like BGP?

Thank you in advance.
Submitted by Anonymous (not registered) on Wed, 2010-01-27 11:40.
Hi Guys,
I want to implement the fail over gateway for local network.
My /etc/network/interface file as below
##########################
# The loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmast 255.0.0.0

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.254.0
network 192.168.0.0
broadcast 192.168.1.255

# The WAN interface 1
auto eth1
iface eth1 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers xxx.xxx.xxx.xxx

# The WAN interface 2
auto eth2
iface eth2 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers xxx.xxx.xxx.xxx

I like local LAN to use gateway from WAN interface 2 upon WAN interface 1 fails.

Any help on this will be much appreciated.
Submitted by Gopal (not registered) on Thu, 2010-08-05 16:07.

Hi :

 Contact me - gopal[AT]viaedge[dot]com for a solution.