Difference between revisions of "Linux/Channel Bonding"

From braindump
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Linux channel bonding with powerline and wireless adapters on Linux}}
{{DISPLAYTITLE:Channel bonding with powerline and wireless adapters on Linux}}


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.
At my home network the Internet router is due to termination limitations sitting in my living room. But all the heavy gear is located 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 ==
== Prerequisites ==
Line 26: Line 26:
* DNS Server: 10.10.10.1
* DNS Server: 10.10.10.1


Since server's wired interface eth0 (10.10.10.2/24) is connected to the one powerline adapter it usually has layer-2 connectivity. Proplems between the two powerline adapters are however not detected as they are completely encapsulated. As such the option <tt>bond-mmion</tt> commonly found in other tutorials will not work for a setup with powerline adapters. The connectity problem will simply not reach the server's eth0 interface. The <tt>bond-arp-interval</tt> in conjuction with <tt>bond-arp-ip-target</tt> ensures that the wired interface (eth0) is only the primary if the default gateway can be reached over that path. In case of the example below the <tt>bond-arp-interval</tt> is set to 1 second (1000 msec) and the <tt>bond-arp-ip-target</tt> to the default gateway 10.10.10.1 which happens to be on the far end of the powerline setup (see the [[#Network Diagram|network diagram]] for a topology overview).
Since server's wired interface eth0 (10.10.10.2/24) is connected to the one powerline adapter it usually has layer-2 connectivity. Proplems between the two powerline adapters are however not detected as they are completely encapsulated. As such the option <tt>bond-mmion</tt> commonly found in other tutorials will not work for a setup with powerline adapters. The connectity problem will simply not reach the server's eth0 interface. The <tt>bond-arp-interval</tt> in conjuction with <tt>bond-arp-ip-target</tt> ensures that the wired interface (eth0) is only the primary if the default gateway can be reached over that path. In case of the example below the <tt>bond-arp-interval</tt> is set to 1 second (1000 msec) and the <tt>bond-arp-ip-target</tt> to the default gateway 10.10.10.1 which happens to be on the far end of the powerline setup (see [[#Network Diagram|topology]]).


# This file describes the network interfaces available on your system
# This file describes the network interfaces available on your system
Line 78: Line 78:
==== Ping Test ====
==== 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 <tt>10.10.10.2</tt>. Walk over to the server with the bonding and rip out the Ethernet cable. The ping should display a little hick-up but continue to work.
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 <tt>10.10.10.2</tt>. Walk over to the server with the bonding and rip out the Ethernet cable. The ping should display a little hick-up but continue to work.

To further check if the whole setup is working if the issue surfaces on the powerline adapter the next test is to unplug the one on closer to the router (see [[#Network Diagram|topology]]) while pinging. After a small delay the ping should continue.


==== Status ====
==== Status ====
Line 109: Line 111:
Permanent HW addr: 00:00:de:ad:be:ef
Permanent HW addr: 00:00:de:ad:be:ef
Slave queue ID: 0
Slave queue ID: 0

=== Different bonding algorithm ===
To see if the <tt>active-backup</tt> setup can be topped using another mode for the bond. I switched the configuration to <tt>balance-rr</tt> and restarted networking. I found that the performance for this [[#Network Diagram|topology]] is slower than only running on the rather slow wireless link only.

==== Speedtest Results ====
The speed was conducted with [https://github.com/sivel/speedtest-cli speedtest-cli] a python script doing the same on the command line as the flash app on [http://speedtest.net speedtest.net].

Running speedtest-cli on an <tt>balance-rr</tt> bond is like hit and miss it does seem to take genrally longer and the variation between the results are quite huge. Your milage may vary but for a similar setup I recommend an <tt>active-backup</tt> setup as it is vastly more reliable and predictable.

===== Powerline (active-backup) =====
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 85.354ms
Testing download speed........................................
Download: <span class="highlight">33.64 Mbit/s</span>
Testing upload speed..................................................
Upload speed: <span class="highlight">24.67 Mbit/s</span>
Share results: http://www.speedtest.net/result/3181185439.png

===== Wireless (active-backup) =====
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 116.984ms
Testing download speed........................................
Download: <span class="highlight">11.16 Mbit/s</span>
Testing upload speed..................................................
Upload speed: <span class="highlight">10.65 Mbit/s</span>
Share results: http://www.speedtest.net/result/3181228681.png

===== Powerline & Wireless (balance-rr) =====
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 124.613ms
Testing download speed........................................
Download: <span class="highlight">17.17 Mbit/s</span>
Testing upload speed..................................................
Upload speed: <span class="highlight">7.39 Mbit/s</span>
Share results: http://www.speedtest.net/result/3181281597.png


== References ==
== References ==
* On a Debian system /usr/share/doc/ifenslave*/README.Debian.gz
* On a Debian system /usr/share/doc/ifenslave*/README.Debian.gz
* [http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding Bonding (Linux Foundation)]
* [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 on RHEL6]
* [https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Using_Channel_Bonding.html Channel Bonding on RHEL6]

Latest revision as of 12:40, 3 January 2014


At my home network the Internet router is due to termination limitations sitting in my living room. But all the heavy gear is located 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.

Configuration Parameters

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 server's wired interface eth0 (10.10.10.2/24) is connected to the one powerline adapter it usually has layer-2 connectivity. Proplems between the two powerline adapters are however not detected as they are completely encapsulated. As such the option bond-mmion commonly found in other tutorials will not work for a setup with powerline adapters. The connectity problem will simply not reach the server's eth0 interface. The bond-arp-interval in conjuction with bond-arp-ip-target ensures that the wired interface (eth0) is only the primary if the default gateway can be reached over that path. In case of the example below the bond-arp-interval is set to 1 second (1000 msec) and the bond-arp-ip-target to the default gateway 10.10.10.1 which happens to be on the far end of the powerline setup (see topology).

# 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-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.

Network Diagram

Channel bonding.png

Final configuration as a network diagram.

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 but continue to work.

To further check if the whole setup is working if the issue surfaces on the powerline adapter the next test is to unplug the one on closer to the router (see topology) while pinging. After a small delay the ping should continue.

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

Different bonding algorithm

To see if the active-backup setup can be topped using another mode for the bond. I switched the configuration to balance-rr and restarted networking. I found that the performance for this topology is slower than only running on the rather slow wireless link only.

Speedtest Results

The speed was conducted with speedtest-cli a python script doing the same on the command line as the flash app on speedtest.net.

Running speedtest-cli on an balance-rr bond is like hit and miss it does seem to take genrally longer and the variation between the results are quite huge. Your milage may vary but for a similar setup I recommend an active-backup setup as it is vastly more reliable and predictable.

Powerline (active-backup)
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 85.354ms
Testing download speed........................................
Download: 33.64 Mbit/s
Testing upload speed..................................................
Upload speed: 24.67 Mbit/s
Share results: http://www.speedtest.net/result/3181185439.png
Wireless (active-backup)
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 116.984ms
Testing download speed........................................
Download: 11.16 Mbit/s
Testing upload speed..................................................
Upload speed: 10.65 Mbit/s
Share results: http://www.speedtest.net/result/3181228681.png
Powerline & Wireless (balance-rr)
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Init 7 (Glattbrugg): 124.613ms
Testing download speed........................................
Download: 17.17 Mbit/s
Testing upload speed..................................................
Upload speed: 7.39 Mbit/s
Share results: http://www.speedtest.net/result/3181281597.png

References