Share, , Google Plus, Pinterest,

Print

Posted in:

Network Bonding on Ubuntu Server 12.04

If you are looking for network card redundancy you can start by confguring network bonding on your Ubuntu Server 12.04 machine. Network cards with network bonding can be joined in multiple configuration options (active/active, active/backup,…). We will configure our network cards in “active/backup” configuration. This is a network bonding fallback configuration which means if one of your network cards fails all of the traffic will be instantly switched to the other, still working network card.

Configuring network bonding is quick and simple, just follow the steps in this guide!

Network bonding
Network bonding

 Requirements:

  • Two network cards available for network bonding

Let’s Configure Network Bonding on Ubuntu Server 12.04!

1. Install required packages

root@foo1:~# apt-get update
root@foo1:~# apt-get install ifenslave

2. Edit /etc/modules file

Edit /etc/modules file and add “bonding” at the end of it.

root@foo1:~# cat /etc/modules 
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

loop
lp
bonding

3. Stop networking

root@foo1:~# /etc/init.d/networking stop

4. Edit /etc/network/interfaces file

Edit /etc/network/interfaces file and configure bonding interface bond0. You also need to change existing eth interfaces to be known as slaves of bond interface by adding “bond-master bond0” to their configuration. There are a couple of bond interface options explained below. Mind the bold text!

root@foo1:~# cat /etc/network/interfaces 
# 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 manual
bond-master bond0
bond-primary eth0

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

# Bonding interface configuration
auto bond0
iface bond0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1
bond-slaves eth0 eth1
bond-miimon 100
bond-mode active-backup

5. Modprobe bonding

root@foo1:~# modprobe bonding

6. Start networking

root@foo1:~# /etc/init.d/networking start

7. Check the status of network bonding

As we can see below, bonding was successfully configured in active-backup mode. Slave interfaces are eth0 and eth1.

root@foo1:~# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

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

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:a8:ab:ab
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:de:fd:85
Slave queue ID: 0

7. Check ifconfig

Again we see that all interfaces are up and running and bond0 interface has the assigned IP address. Network bonding on Ubuntu Server 12.04 is working as expected.

root@foo1:~# ifconfig
bond0     Link encap:Ethernet  HWaddr 08:00:27:a8:ab:ab  
          inet addr:192.168.61.164  Bcast:192.168.61.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea8:abab/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:2279 errors:0 dropped:3 overruns:0 frame:0
          TX packets:1127 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2557592 (2.5 MB)  TX bytes:217603 (217.6 KB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:a8:ab:ab  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:2272 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1127 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2556425 (2.5 MB)  TX bytes:217603 (217.6 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:a8:ab:ab  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:3 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1167 (1.1 KB)  TX bytes:0 (0.0 B)

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:65536  Metric:1
          RX packets:156 errors:0 dropped:0 overruns:0 frame:0
          TX packets:156 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:12688 (12.6 KB)  TX bytes:12688 (12.6 KB)

Share, , Google Plus, Pinterest,

One Comment

Leave a Reply