[lug] Bonding (ifenslave) eth0 and wlan0 in 'laptop mode'

Stephen Queen svqueen at gmail.com
Tue Nov 25 10:41:07 MST 2014


What I was trying to accomplish was this. I was trying to make a laptop
connect to the same network through one of two interfaces. If the user
pluged into the network with a network cable, then the wired interface
should work. If the user didn't plug into the network with a cable, then
the wireless interface should connect. If the user removes the plug, then
the wireless network should connect.

I found a solution, and it was much easier than I was making it. I had
googled it, and found the bonding solution, which I was never able to make
work. The simple solution was to use ifplugd in conjunction with whereami.
On debian when you load whereami you also get resolvconf. I could have
gotten away with just the simple ifplugd, but if you boot with no cable
connected, then the wireless interface doesn't automatically come up. This
method doesn't switch instantly like bonding was touted to do, but it does
switch interfaces fairly rapidly. For what it's worth, here are my config
files.

cat /etc/network/interfaces
auto lo
iface lo inet loopback

# Notice that there are no auto stanzas in the eth0 or wlan0.
# The dns-nameservers stanzas are used by resolvconf
iface eth0 inet static
        address 10.14.1.6
        netmask 255.255.0.0
        broadcast 10.14.255.255
        network 10.14.0.0
        dns-nameservers 8.8.8.8 4.4.4.4

iface wlan0 inet static
        wireless-essid Newtem
        wireless-mode Managed
        wireless-channel 6
        address 10.14.1.6
        netmask 255.255.0.0
        broadcast 10.14.255.255
        network 10.14.0.0
        dns-nameservers 8.8.8.8 4.4.4.4

cat /etc/default/ifplugd
INTERFACES="eth0"
HOTPLUG_INTERFACES=""
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

cat /etc/ifplugd/action.d/ifupdown
#!/bin/sh
# Maybe drop the case and just execute /usr/sbin/whereami whenever this is
called.
set -e

case "$2" in
up)
        /usr/sbin/whereami
        ;;
down)
        /usr/sbin/whereami
        ;;
esac

cat /etc/whereami/detect.conf
# It is a good idea to default to somewhere...
default     wlan
# Test for the presence of an ethernet connection plugged into eth0
testmii     eth0          lan
# Get a list of the access points that we can see
if lan
  notat         wlan
elseif
  set INTERFACE wlan0
  testap      scan   wladapter
  notat         lan
fi

if wladapter
  testap Newtem wlan
fi

cat /etc/whereami/whereami.conf
## This only happens if we are not at a WLAN
!wlan ifdown wlan0
## This only happens if we are not at a LAN
!lan ifdown eth0
## Setup wlan connections
#=lan ifdown wlan0
=lan ifup eth0

#=wlan ifdown eth0
=wlan ifup wlan0


Hope this saves someone some time someday.

Steve

On Tue, Nov 11, 2014 at 8:08 AM, Stephen Queen <svqueen at gmail.com> wrote:

> I'm trying to bond to interfaces using ifenslave on a debian laptop into a
> single bond0 interface. I see from this wiki entry that it should be
> possible.
> https://wiki.debian.org/Bonding
> See example 2.
>
> The following is from /etc/network/interfaces
> auto eth0
>         iface eth0 inet manual
>         bond-master bond0
>         bond-primary eth0
>         bond-mode active-backup
>
> auto wlan0
>         iface wlan0 inet manual
>         wireless-essid Newtem
>         wireless-mode Managed
>         wireless-channel 6
>         bond-master bond0
>         bond-primary eth0
>         bond-mode active-backup
>         bond_updelay 200
>         bond_downdelay 200
>
> auto bond0
>         iface bond0 inet static
>         address 10.14.1.6
>         netmask 255.255.0.0
>         broadcast 10.14.255.255
>         network 10.14.0.0
>         bond_updelay 200
>         bond_downdelay 200
>         bond-slaves none
>         bond-primary eth0
>         bond-mode active-backup
>         bond-miimon 100
>
> This is what cat /proc/net/bonding/bond0  produces
> 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): 200
> Down Delay (ms): 200
>
> Slave Interface: eth0
> MII Status: up
> Speed: 100 Mbps
> Duplex: full
> Link Failure Count: 2
> Permanent HW addr: c4:54:44:52:52:77
> Slave queue ID: 0
>
> Here is what dmesg has to say about it
> [   11.934232] bonding: bond0: making interface eth0 the new active one.
> [   11.934310] bonding: bond0: first active interface up!
> [   11.934352] bonding: bond0: enslaving eth0 as an active interface with
> an up link.
> [   11.934794] ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
> [   12.125464] bonding: bond0: Unable to set down delay as MII monitoring
> is disabled
> [   12.125679] bonding: bond0: Unable to set up delay as MII monitoring is
> disabled
> [   12.128778] bonding: unable to update mode of bond0 because interface
> is up.
> [   12.133440] bonding: bond0: Setting eth0 as primary slave.
> [   12.141875] bonding: bond0: Adding slave wlan0.
> [   12.294898] bonding: bond0: Setting MII monitoring interval to 100.
> [   12.294986] bonding: bond0: Setting down delay to 200.
> [   12.295047] bonding: bond0: Setting up delay to 200.
> [   12.296795] bonding: unable to update mode of bond0 because interface
> is up.
> [   12.298352] bonding: bond0: Setting eth0 as primary slave.
> [   12.317179] bonding: bond0: link status down for active interface eth0,
> disabling it in 200 ms.
> [   12.516046] bonding: bond0: link status definitely down for interface
> eth0, disabling it
> [   12.516097] bonding: bond0: now running without any active interface !
>
> Output of ifconfig
> bond0     Link encap:Ethernet  HWaddr c4:54:44:52:52:77
>           inet addr:10.14.1.6  Bcast:10.14.255.255  Mask:255.255.0.0
>           inet6 addr: fe80::c654:44ff:fe52:5277/64 Scope:Link
>           UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
>           RX packets:1731 errors:0 dropped:7 overruns:0 frame:0
>           TX packets:686 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:166224 (162.3 KiB)  TX bytes:178171 (173.9 KiB)
>
> eth0      Link encap:Ethernet  HWaddr c4:54:44:52:52:77
>           UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
>           RX packets:1731 errors:0 dropped:1 overruns:0 frame:0
>           TX packets:686 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:166224 (162.3 KiB)  TX bytes:178171 (173.9 KiB)
>           Interrupt:72
>
> 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:16436  Metric:1
>           RX packets:110 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:110 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0
>           RX bytes:8492 (8.2 KiB)  TX bytes:8492 (8.2 KiB)
>
> wlan0     Link encap:Ethernet  HWaddr c4:54:44:52:52:77
>           inet6 addr: fe80::c654:44ff:fe52:5277/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:355 errors:0 dropped:0 overruns:0 frame:32338
>           TX packets:37 errors:1 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:14910 (14.5 KiB)  TX bytes:5720 (5.5 KiB)
>           Interrupt:28
> Output of iwconfig
> wlan0     IEEE 802.11abg  ESSID:"Newtem"
>           Mode:Managed  Frequency:2.437 GHz  Access Point:
> B4:B6:76:4F:0A:F1
>           Tx-Power=200 dBm
>           Retry  long limit:7   RTS thr:off   Fragment thr:off
>           Encryption key:off
>           Power Management:off
>
> Anyone ever successfully accomplish this? Any ideas on how to get it
> working?
>
> Thanks,
> Steve
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20141125/01b1bbde/attachment.html>


More information about the LUG mailing list