How to create a Wifi to Freifunk-LAN bridge from Raspberry Pi 3
This article covers adding another network device to gluon. As well as configuring a RaspberryPi3 as a Wifi to LAN bridge. The reasons are purely educational, as much better hardware is available and the Raspberry Pis are all but a good wifi router.
The easy part - USB-Ethernet adapter
I tried adding a LAN adapter to the Raspberry Pi 3 B - because I have one laying around, and always had issues with them when using Proxmox, but I want to see if they work reliable when connected to openwrt directly.
Gluon does not autoconfigure new devices when they are attached after the first installation (or part of the board config, I don’t know). So we have to add this ourselves.
After attaching the USB-Ethernet adapter to the USB port of the RPI3, the device is recognized as an unconfigured eth1
.
To add this to gluon we use:
uci set gluon.iface_lan=interface
uci set gluon.iface_lan.name=eth1
uci set gluon.iface_lan.role=client # or use mesh here
uci commit gluon
to apply the changes we run:
gluon-reconfigure
reboot # or just `/etc/init.d/network restart`
Fine, we are done. These are exactly the same instructions as needed when creating a VM with more than 2 network adapters.
The WIFI config
When adding the wifi interface directly to a bridge, the wifi interface does not work and complains about can't add wlan0 to bridge wan: Operation not supported
https://forums.raspberrypi.com/viewtopic.php?t=132674#p973237
Instead of going weird ways as stated in this thread: https://serverfault.com/questions/152363/bridging-wlan0-to-eth0
I somehow managed to get it working differently:
1. add new iface to gluon
uci set gluon.iface_wan0=interface
uci set gluon.iface_wan0.name=fallback
uci add_list gluon.iface_wan0.role=uplink
uci commit gluon
This creates a new interface, which is automatically added to the wan bridge.
uci show network.wan
should show something like network.wan.ifname='eth0' 'wan0'
after applying the change.
2. Disable wifi config
As mesh is broken on RPI3 due to missing 802.11s support, we need to disable the existing wifi configuration (disable, not remove - otherwise the will be enabled on reconfigure).
uci set wireless.client_radio0.disabled='1'
uci set wireless.mesh_radio0.disabled='1'
uci commit wireless
3. add uplink wifi
uci set wireless.wan_radio0=wifi-iface
uci set wireless.wan_radio0.ifname='wan0' # this must match the name of the ifname as `iface_wan0`
uci set wireless.wan_radio0.network='fallback' # this must match the .name of the network
uci set wireless.wan_radio0.disabled='0'
uci set wireless.wan_radio0.device='radio0'
uci set wireless.wan_radio0.mode='sta'
uci set wireless.wan_radio0.macaddr='9a:96:1d:92:64:7b'
uci set wireless.wan_radio0.encryption='psk2'
uci set wireless.wan_radio0.ssid='YOUR-WAN-SSID'
uci set wireless.wan_radio0.key='your-wan-wifi-password'
uci commit wireless
or edit the file /etc/config/wireless
accordingly
config wifi-iface 'wan_radio0'
option ifname 'wan0'
option network 'fallback'
option disabled '0'
option device 'radio0'
option mode 'sta'
option encryption 'psk2'
option ssid 'YOUR-WAN-SSID'
option key 'your-wan-wifi-password'
option macaddr '9a:96:1d:92:64:7b'
4. apply changes
if you now run gluon-reconfigure
, your changes should not be overwritten.
To apply the added network run /etc/init.d/network restart
.
And to restart wifi accordingly run wifi
.
This should show wan0: link becomes ready
if everything works.
Wrap up
This configuration is probably safe to updates on the RPI3 as the other wifis are turned off and we added our network properly.
I first just added network.wan.ifname='eth0' 'fallback'
which did not work.
I first tried to add a own interface wan0n
instead of fallback
, which did not work.
I looked into how the ffac-autoupdater-wifi-fallback handles this and therefore used the fallback interface from there and only added this interface to the proper wan uplink - which makes things easier.
If the package is not installed on your node, you manually have to make sure, that
config interface 'fallback'
option sourcefilter '0'
option proto 'dhcp'
option peerdns '1'
exists on the node, else no dhcp is requested on the wifi.
I somehow could not get this to work with br-wan
. So thats how it is..
Eventually, this can be useful to connect a gluon node to a WAN over wifi connection if nothing else is possible.
I am curious, if this works similar on actual wifi routers, which can mesh additionally and properly handle multiple wifis.
Edit: This also worked sucessfully on a Fritz Repeater 1200 - so this post can be adapted to other devices too.