Bonding eth0 and wlan0

So since I’m using my Pi for some network functions, I figured it’d be nice to have a single IP to consistently reach the device, regardless of whether a cable is handy or not.

Since my router is smart enough to disallow pre-configuring the DHCP server to assign the same IP to multiple MACs (and no one likes IP address conflicts), I went with bonding.

My starting point was debian’s wiki:

In Raspbian, a new package is needed:

# apt-get install ifenslave

Don’t forget to tell the kernel to start the bonding module at each boot-up:

# echo 'bonding' >> /etc/modules 

So I got the lion’s share of my setup from there (with some adjustments) – here is the final version:

# Define slaves   
auto eth0
iface eth0 inet manual
    bond-master bond0
    bond-primary eth0
    bond-mode active-backup
auto wlan0
iface wlan0 inet manual
    wpa-conf /etc/network/wpa.conf
    bond-master bond0
    bond-primary eth0
    bond-mode active-backup

# Define master
auto bond0
iface bond0 inet dhcp
    slaves         eth0 wlan0
    bond_mode      active-backup
    bond_miimon    100
    bond_downdelay 200
    bond_updelay   200

Thanks to a forum post I’ve lost track of, I also figured out that I had to comment out the line I had previously added to address an issue getting dhcp addresses:

# iface default inet dhcp

The current delay is 5min 11sec from reboot to ping(out).

When plugging-unpluging the Eth cable, one can clearly see the difference in ping-times (~5ms vs. ~0.5ms), but no requests/replies get dropped!



I reproduced this on a brand-new minimal-install of Raspbian (4.4.50-v7+) and folowed my own steps.

BUT, for some reason, when booting with eth0 connected, eth0 would grab the IP (instead of bond0 doing so) and I was unable to ping my router(!?).

Disconnecting eth0, the IP would toggele over to bond0 and everything worked well (pinging over wlan0), so I reconnected the cable and it still worked (pinging over eth0)… or 5 seconds, after which, the IP switched back to eth0 and ping connectivity was lost!?

The only other changes I made before it started workign again were:

  • disable “alsa-utils” sound driver/service (update-rc.d alsa-utils disable)
  • comment out the plaintext ‘key’ line in /etc/wpa-supplicant/wpasupplicant.conf

… Wierd, right??




Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s