Difference between revisions of "Linux/Channel Bonding"

From braindump
Jump to navigation Jump to search
Line 109: Line 109:
* [http://www.lemmster.de/blog/index.php/2013/06/21/1296 Network bonding (wlan & eth) on linux ubuntu]
* [http://www.lemmster.de/blog/index.php/2013/06/21/1296 Network bonding (wlan & eth) on linux ubuntu]
* [https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Using_Channel_Bonding.html Channel Bonding RHEL6]
* [https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Using_Channel_Bonding.html Channel Bonding RHEL6]
* [http://en.wikipedia.org/wiki/Channel_bonding Channel bonding on wikipedia]

[[Category: Linux]]
[[Category: Linux]]

Revision as of 22:56, 21 December 2013


At my home network I my Internet router is unfortunately is due to termination limitations sitting in my living room. But all the heavy gear is at the other end of the apartment in my office. To connect the two rooms I use two power line devices. Unfortunately they are not as reliable as they should be. Especially during heavy downloading they get the panties in a not and traffic does no longer pass. To remedy the problem I thought having a backup link via wireless might be a good idea. Here is how I did it.

Prerequisites

  • A linux host with a wired (eth0) and a wireless (wlan0) interface. This example is for Debian/Ubuntu
  • ifenslave

Howto

Disable NetworkManager

This example is for a headless machine which is using only statically assigned addresses. As such NetworkManager is not required. Hence the first thing is to ensure it no longer runs. On the Ubuntu 12.04 LTS host I used for the configuration I did it this way. Your milage may vary depending on the particular flavor or version.

echo manual > /etc/init/network-manager.override

Configure /etc/network/interfaces

The assumption is made that the reader already understands the basic principles of interface bonding. So there is not a lot of detail other than the points to be considered for this type of setup.

For the example below we take the following parameters:

  • SSID: foobar
  • PSK: YourSecretPreSharedKey
  • Primary Interface: eth0
  • Secondary Interface: wlan0
  • Bonding Interface: bond0
  • Host IP: 10.10.10.2/24
  • Default Gateway: 10.10.10.1
  • DNS Server: 10.10.10.1

Since I have a powerline adapter connected to my hosts wired interface eth0 (10.10.10.2/24) which will generally always have a link signal the bonding will not detect any imminent connection loss on the link. To ensure detection of issues on the link the options bond-mmimon, bond-arp-interval and bond-arp-ip-target are used help with the link detection. Actually bond-mmion invalidates bond-arp-interval use either or of the two.

# 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

auto eth0
iface eth0 inet manual
          bond-master bond0
          bond-primary eth0 wlan0 

auto wlan0 
iface wlan0 inet manual
          wpa-ssid "foobar"
          wpa-psk "YourSectretPreSharedKey"
          bond-master bond0
          bond-primary eth0 wlan0 

auto bond0 
iface bond0 inet static 
          bond_mode active-backup
          bond-miimon 1000
          bond-arp-interval 1000
          bond-arp-ip-target 10.10.10.1
          bond-primary eth0
          slaves eth0 wlan0
          address 10.10.10.2
          netmask 255.255.255.0
          gateway 10.10.10.1
          dns-nameservers 10.10.10.1
iface bond0 inet6 static
          address xxxx:xxxx:xxxx:xxxx::1
          netmask 64
          scope global

Restarting networking

Whenever making changes to networking ensure you have a way to restore the config via serial console or being logged in on directly on the host. Not that I ever knocked myself out of a host by getting the parameters wrong ;).

/etc/init.d/networking restart 

Check if the link is working trying to log via ssh.

Testing

Ping Test

To test the if the configuration works as expected use a device on the same network to continuously ping the IP address of the bonding address just configured. In this example that is 10.10.10.2. Walk over to the server with the bonding and rip out the Ethernet cable. The ping should display a little hick-up put continue to work.

Status

To be double sure check the status of the bonding interface via the proc filesystem. After ripping out the Ethernet cable the Currently Active Slave should be the wlan0 interface. After seating the Ethernet cable back into the socket it should fall back to be eth0.

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: wlan0
MII Status: up
MII Polling Interval (ms): 1000
Up Delay (ms): 0
Down Delay (ms): 0 

Slave Interface: eth0
MII Status: down
Speed: 10 Mbps
Duplex: half
Link Failure Count: 1
Permanent HW addr: 00:00:de:ad:be:ef
Slave queue ID: 0 

Slave Interface: wlan0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:00:de:ad:be:ef
Slave queue ID: 0

References