Beck's *nix Blog

All things Linux and Unix

Networking bonding in Debian/Ubuntu, Active-Backup mode…

1 Comment

Quick Note on Bonding/Teaming/Port Trunking

Bonding was designed to achieve several things but the most common are High Availability and better throughput.

My problem:

While I primarily use LACP (mode 4) for everything I got stuck working on a low budget project and still needed HA for Ubuntu Server 12.04. As usual I asked Google which led me to this document. Then there was the kernel documentation and that was the best my searches returned. Everything else was outdated or just wrong.

First off, if its in your budget don’t be cheap and just buy stackable switches. Its the best of both worlds, HA and increased throughput. If you are limited to dumb or manageable switches that do not support stacking, this is for you.

Installing ifenslave:

sudo apt-get install ifenslave

Configuring Active/Backup (mode 1):

This is a relative simple concept but your switches better be configured right.

First is the module initialization. Create /etc/modprobe.d/bonding

 alias bond0 bonding
 options bonding mode=1 miimon=100
 alias bond1 bonding
 options bonding mode=1 miimon=100

This will ensure that the modules is properly initialized between reboots.

Next edit your /etc/network/interfaces file.

 auto lo
 iface lo inet loopback

 # Bond0 interface
 auto bond0
 iface bond0 inet static
 address 192.168.1.101
 netmask 255.255.255.0
 gateway 192.168.1.1
 bond-mode 1
 bond-slaves none
 bond-miimon 100

 # The primary network interface
 auto eth1
 iface eth1 inet manual
 bond-master bond0
 bond-primary eth1 eth2

 # The secondary network interface
 auto eth2
 iface eth2 inet manual
 bond-master bond0
 bond-primary eth1 eth2

 # Bond1 interface
 auto bond1
 iface bond1 inet static
 address 10.1.1.101
 netmask 255.255.255.0
 bond-mode 1
 bond-slaves none
 bond-miimon 100
 post-up ip route add 10.0.0.0/8 via 10.1.1.1 dev bond1

 # The primary network interface
 auto eth3
 iface eth3 inet manual
 bond-master bond1
 bond-primary eth3 eth4

 # The secondary network interface
 auto eth4
 iface eth4 inet manual
 bond-master bond1
 bond-primary eth3 eth4

Couple things to note here. The first gateway you enter will become the default route (0.0.0.0). Therefore you must add any additional routes using the post-up keyword.

Now simply restart networking or reboot. I choose the reboot method to ensure everything started up properly (not just networking but other services needed) and of course I found a few typos on some servers.

You can also use Balance-RR (mode 0) but it tends to result in additional overhead since it sends and receives packets out of order.

Advertisements

One thought on “Networking bonding in Debian/Ubuntu, Active-Backup mode…

  1. Pingback: Debian-Installation mit zwei Netzwerkkarten ausfallsicher(er) machen « think eMeidi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s