Enable Port forwarding for Raspberry Pi OTG network

I am attempting to translate Alex Ellis’ Recipe to Create a Raspberry Pi OTG network to work on Resin.io.

I have been able to setup and ping the RPI Zero Client from the RPI 3 Host:

caption: this is the RPI 3 host, notice that eth1 is the usb otg device and that ping is working

caption: this is the RPI Zero W client, notice usb0 with static IP. I have left both RPI Zero and 3 connected via wifi to Resin.io in this case.

caption: this is the connection file on RPI3 host

caption: this is the connection file on RPI Zero W client

I have followed @Cwright11 forum posting on a similar topic where the conclusion was to change ‘ivp4’ settings of ‘mode=manual’ to ‘mode=share’ where the default is 10.42.x.1 as mentioned in the NetworkManager documentation.

I have tried many variations including attempting to change the IP addresses on the ethernet peripherals. The only configuration that I have found that maintains the static IP assignments and that functions as expected is the case I have shown above.

Open questions:

  1. How do I successfully IP forward yet maintain the IP addresses that work with the OTG Ethernet Gadget on RPI Zero W?
  2. How to put in place UDEV rules as shown in the recipe to enable multiple RPI Zero W?

Please forgive my ignorance if I am missing something elementary. I am relatively new to networking and am frustrated by the gaps in my knowledge of basic concepts. Thank you for considering this.

Hi @jdaniellhebert

You will need to put the udev rules onto the host file system by burning the image and then mounting it on your computer.

Perhaps the IP forwarding stuff is related to this issue? It might be a good idea to try and get this working on raspbian with NetworkManager as a first step?

If I am understanding this correctly, you are suggesting this may only work if I use the correct release of Raspbian? Thank you for the mounting tip, I will try this tomorrow.

I am suggesting that you try it with Raspbian and network manager as that removes the resin component from the mix, and once that works, have another go at moving it over to resin.

hi @joe, after much work in the background and some back channel feedback via resin bizdev (and resin team), I think I am going to abandon this approach for now. There seems to be a hypothesis that the g_ether drivers are not stable (sensitive to power fluctuations and data noise on poor usb cables). What I managed to accomplish with my work was to configure and get repeatable fixed IP addresses configured (using resin dev image) but at some point using ‘dmesg’ found that there were a lot of errors and corrupted packets being transferred. From some web searches there seemed to be some indication this might be a memory leak in the drivers, though that was scoffed at too: no idea.

So I am now onto an alternative approach for my prototype, namely making the same network connections that i wanted to make via OTG via wifi instead.

I am attempting to build a system where i connect multiple rpi0ws via an AP that has two wifi connections. The goal is to connect all the rpi0ws through one wifi connection to the web and have them connect to and be managed by the resin system.

I have taken the approach outlined in: Creating access point - Raspberry Pi Zero W. At a high level the AP seems to work when implemented rpi3 and following the suggestions. I am able to connect with my laptop to the web through the AP. However shortly after that success the connection drops until i reconnect again. I also have tried to set up one of the rpi0w to connect to the ‘resin-hotspot’ side of the AP. When I scan the ports of this network from my laptop I see the rpi0w on the ‘resin-hotspot’. However again, shortly after this the network disconnects. I have the sense (but am not sure how to instrument) that incoming traffic back through the AP causes the disconnection.

Consequently, I have a few questions:

  1. What is causing the downstream side (resin-hotspot) to disconnect?
  2. Is there some configuration required on the rpi0w to allow them to get through the AP and to connect to resin?
  3. How would you suggest instrumenting this system to figure out what is happening?

Thanks for your consideration of these questions!

Hey @jdaniellhebert

  1. Not sure to be honest, please try the below:

How do you have the AP Pi connected to the internet? If it’s connected over ethernet you should be able to host the AP using the onboard WiFi, if you’re connecting over WiFi you will need an extra WiFi interface for the AP i.e. a USB WiFi dongle. (you can’t use the same interface to both connect to the internet and host the AP)

I would create the hotspot using nmcli from the host of a dev image - here are the commands needed:

nmcli c add type wifi ifname <WIFI-INTERFACE (e.g. wlan0)> con-name resin-hotspot autoconnect no ssid resin-hotspot
nmcli connection modify resin-hotspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli connection modify resin-hotspot wifi-sec.key-mgmt wpa-psk
nmcli connection modify resin-hotspot wifi-sec.psk "resin-hotspot"
nmcli connection up resin-hotspot

You can find the WIFI-INTERFACE name using nmcli d. This would create a hotspot called resin-hotspot with the password resin-hotspot

  1. You need to setup the zeros to connect to the hotspot using the credentials above. The easiest way to do this is to configure the image when you download it from the dashboard.

  2. If the connection still drops with the above I would check both nmcli c and nmcli d, dmesg and journalctl -fn 100 -u NetworkManager

Post any logs here and let me know how you get on.