Bridge network interfaces Rpi 3


#1

I’d like to create a wireless bridge between the RPi’s Ethernet and wireless interfaces. The purpose of the bridge is to share the wifi Internet connection with a connected Ethernet device. I’ve previously set it up on a RPi 3 using the instructions shown in this link. However, in the docker container it doesn’t seam to work. I can ping ping the Ethernet device from inside the contain but not from other devices on the wifi network.

What is the best way to setup a wireless bridge between the RPi’s Ethernet and wireless interfaces?

Thanks


#2

Hey,

I tried to recreate the problem, but this works fine for me. Can you share more information? Also, did you configure the routing tables on the devices on your wifi network you’re pinging from?


#3

Can you share the code you were using to try setting up the bridging? That might help debugging the issues.


#4

I attempted to create a wireless bridge between the RPi’s Ethernet and wireless interfaces using Proxy ARP. Proxy ARP is a routed (Layer 3) solution, but works for all IP traffic: see https://wiki.debian.org/BridgeNetworkConnectionsProxyArp for details.

The steps I followed are as follows:

sudo apt-get install parprouted dhcp-helper avahi-daemon

Edit /etc/network/interfaces to configure the interfaces:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  post-up /usr/sbin/parprouted eth0 wlan0
  post-down /usr/bin/killall /usr/sbin/parprouted
  # clone the dhcp-allocated IP to eth0 so dhcp-relay will relay for the correct subnet
  post-up /sbin/ip addr add $(/sbin/ip addr show wlan0 | perl -wne 'm|^\s+inet (.*)/| && print $1')/32 dev eth0
  post-down /sbin/ifdown eth0

Edit /etc/sysctl.d/local.conf to enable IP forwarding:

net.ipv4.ip_forward=1

Enable DHCP relay: /etc/default/dhcp-helper

# relay dhcp requests as broadcast to wlan0
DHCPHELPER_OPTS="-b wlan0"

Edit /etc/avahi/avahi-daemon.conf to enable mDNS relaying:

[reflector]
enable-reflector=yes

Reboot

The avahi messages send from the device connected to the RPi’s ethernet port are visible to devices on the WiFi network, however when I try to ping the IP address of the ethenet connected device from a device connected to the WiFI network I get a ‘Destination Host Unreachable’


#5

I’m not sure I get it, sorry, where did you take these steps? What Dockerfile have you tried to use exactly? Is it deployed on resin.io?


#6

I used the resin/%%RESIN_MACHINE_NAME%%-python using a Raspberry Pi. It is deployed on resin.io


#7

These steps were taken inside the Docker container.


#8

Hey @zuma, one important note in the beginning. If you modify things in a running container, and you restart from that, all your changes will be lost as the container itself is immutable (always starts from the same initial setup). So that way you tried to set things up wouldn’t have worked anyways.

I’ve looked into the links you mentioned, and made a “resinified” version of the bridge, you can get it from there (clone it, and then push the code to your own application):

The code implements the same steps as the Debian Wiki describes, but in a container:

  • installs the required packages
  • creates the relevant config files for dhcp-helper and avahi-daemon and copy them in the container to the right location
  • creates a start script which:
    • enables IP forwarding and ARP proxying
    • clones the IP address from wlan0 to eth0
    • starts the parprouted proxy

I’ve tried it out, and this works okay in general, I could connect another device over Ethernet and get network. I’m sure it could be more fine-tuned and adjusted to particular use cases, but this is the basic setup, IMHO.

Let us know what do you think if you try it!


#9

Hey @imrehg, it works perfectly!
Thanks for going to the effort of setting up a repo with the solution, I really appreciate it.


#10

Hey @imrehg, sorry for posting here in this old thread, but i have a question,
i’m trying to get this work on the actual version of resinOS… “Resin OS 2.12.6+rev1” but it doesn’t works… is that because of the version? what could i do to make it work?

Thank you very much


#11

Hey @imrehg

I’m currently testing resin.io on an industrial board and one of my needs is for the wireless hotspot to only have access to the docker containers and not through the LTE connection to the internet. It looks like this could be easily modified to perform that action for me.


#15

I’ve started a new thread to cover this scenario here:

If you figure it out please let me know.