Okay, I am going to resurrect this thread a bit.
While setting up bond between eth0 and wlan0, same as you, I encountered a strange problem. I managed to solve this problem prior to writing this post, but I am writing this just no one else will struggle same as me for almost a week...
So, I set up my bond with configurations by marcelser (
memberlist.php?mode=viewprofile&u=235138) with the exception of using static IP instead of DHCP.
/etc/modprobe.d/bonding.conf
Code: Select all
options bonding fail_over_mac=none mode=active-backup primary=eth0 primary_reselect=always
/etc/network/interfaces
Code: Select all
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
bond-master bond0
bond-mode active-backup
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
bond-master bond0
bond-mode active-backup
auto bond0
#iface bond0 inet dhcp
iface bond0 inet static
address 192.168.0.151
netmask 255.255.255.0
gateway 192.168.0.1
dns-search google.com
dns-nameservers 192.168.0.1 8.8.8.8
bond-slaves none
bond-primary eth0
bond-mode active-backup
bond-miimon 200
bond-fail_over_mac follow
bond-primary_reselect always
bond-updelay 200
bond-downdelay 0
hw-address 8c:ae:4c:eb:94:90
I also edited /etc/dhcpcd.conf with "denyinterfaces eth0 wlan0" just as him for the same reason.
The problem:
But there was a strange problem with this configuration. Devices wihich had wired connection to my network, could ping the RPi without problem. But wireless devices could not estabilish any kind of connection to the RPi other than ARP Discovery, and ARP Response packets. So the wired devices could conncet to the RPi, the wireless could not, but, when I unplugged the ethernet cable from the RPi, RPi failed-over to using wlan0 interface. At this state, all devices were able to ping the RPi, wired as well as wireless. But with the ethernet cable connected to the RPi, wireless devices could not connect again.
Interesting was, that shutting down the wlan0 interface on RPi caused that wireless clients on the network could ping RPi sucesfully, but that is not what fail redundacy means, so this is not plausible configuration.
Explanation of the cause:
Turns out, it was caused by multiple things. 1. When you bond interfaces in Active-Backup mode, all physical interfaces will have same MAC address. I knew that before.
But now, on the multifunction networking device, or as it is mor known "Wi-Fi router", there is same MAC adress twice. One is on internal switch, where eth0 is connected, and second is on wireless switch where wlan0 is connected.
Some//most of these Wi-Fi routers have implemented algorithm for matching packet dest.MAC to MAC in ARP table. But apparentely, the algorithm firstly searches for the mac on the interface on which the packet was recieved, and then on other interfaces.
But because there is same MAC on WIreless and on Integrated switch, from wireless device the first MAC matches the wlan0 interface of the RPi, so it sends packet over Wi-Fi to the wlan0 interface. But becuase on RPi is wlan0 in bond, and the currently active interface is other than wlan0 (in our case eth0 is active interface as long as the cable is connected), the packet on wlan0 will be dropped, and thus, system of RPi never knew about that someone is trying to ping it.
So basically what is happening is:
0. Some wireless device sends ICMP (ping) Request.
1. The ICMP request arrives to the Wi-Fi router on wireless interface.
2. The Wi-Fi router searches MAC address on wireless interface for matching MAC address.
3. The MAC of wlan0 of the RPi matches, so the Wi-Fi router sends packet wirelessly to wlan0 of the RPi.
4. On the RPi the wlan0 interface gets ICMP request packet, and as configured, forwards it to the bond0 interface.
5. bond0 receives the packet, but becuase wlan0 IS NOT currently active interface (the eth0 is) it drops the ICMP request. The journey of this packet here ends.
So,
how to fix that?
We could repair/modify the algorithm on the Wi-Fi router, but that would require much more research, informations and time... not a viable option.
We could make MAC addresses of eth0 and wlan0 different. Yes, whis would be easy and work, but any time fail-over to wlan0 or fail-back to eth0 should happen, the ARP table entry on the Wi-Fi router and/or network devices would have to change every time, and that takes time, so it would disrupt the communication while fail-over or fail-back is happening. Easy? Yes. Viable? No!
THE SOLUTION:
Turns out, the bond module has kernel parameter for that! Name of the parameter is
all_slaves_active .
The official linux documentation describes what it does perfectly:
all_slaves_active
Specifies that duplicate frames (received on inactive ports) should be
dropped (0) or delivered (1).
Normally, bonding will drop duplicate frames (received on inactive
ports), which is desirable for most users. But there are some times
it is nice to allow duplicate frames to be delivered.
The default value is 0 (drop duplicate frames received on inactive
ports).
YES! This sounds like exactly the parameter we need, and sure enough, just as I changed it from 0 to 1, the wireless devices started getting ICMP (ping) replies! Only thing we need is to set this parameter to 1 at the boot time the kernel is loaded. For that to happen only thing you need to do is add:
to file
/etc/modprobe.d/bonding.conf .
And that, is all we have to do to get it working!
Here are my current configs:
/etc/modprobe.d/bonding.conf
Code: Select all
options bonding mode=active-backup primary=eth0 primary_reselect=always fail_over_mac=none all_slaves_active=1
/etc/network/interfaces
Code: Select all
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
###source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
bond-master bond0
# bond-primary eth0 wlan0
bond-mode active-backup
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
bond-master bond0
# bond-primary eth0 wlan0
bond-mode active-backup
auto bond0
#iface bond0 inet dhcp
iface bond0 inet static
address 192.168.0.151
netmask 255.255.255.0
gateway 192.168.0.1
dns-search google.com
dns-nameservers 192.168.0.1 8.8.8.8
bond-slaves none
bond-primary eth0
bond-mode active-backup
bond-miimon 200
bond-fail_over_mac follow
bond-primary_reselect always
bond-updelay 200
bond-downdelay 200
# hw-address dc:a6:32:3f:63:a9
And line
in
/etc/dhcpcd.conf .
I hope this post once saves someone struggling with this or similiar problem a LOT of time.
And if it saved you a lot of time, please say "thanks" for my week of hell, terror, depression and confusion.