Hey there,
first off, merry belated christmas to you all, I hope you had a nice christmas week.
I’m currently trying out Balena for an IoT-ish project and at this point I’ve happened across some networking issues that I seem incapable of resolving on my own. I’ve never worked with NetworkManager before, so I’m struggling a bit to wrap my head around getting it to do what I want it to, so I figured I’d ask for help here.
My setup is as follows:
- I have multiple Balena-imaged devices with network connectivity (Ethernet)
- I have one “main” device (also Balena-imaged) which has multiple network interfaces
The main device is a Raspberry Pi 4B. It has two ethernet ports (one via a USB adapter for the time being) and WiFi. The other devices have one ethernet port each.
I would like to set the Pi up such that it can intake an existing internet connection through some means (either one of the Ethernet ports or possibly a GSM modem later down the line) and subsequently act as a router for all “downstream” devices. A switch is hooked up to one of the ethernet ports, and several more devices are connected to that switch.
The end goal I have in mind would be for the Pi to work as a “router” in the sense that all downstream devices and the WiFi would be in one network, with internet connectivity supplied to the Pi through a secondary interface. Let us assume this is another ethernet port to make this more concrete.
I’ve attached an image showing what I have in mind below.
I already have some progress towards this goal, but it’s not quite there yet.
I first created a WiFi hotspot according to Balena’s networking documentation:
[connection]
id=balena-hotspot
type=wifi
autoconnect=true
interface-name=wlan0
permissions=
secondaries=
[wifi]
band=bg
mac-address-blacklist=
mac-address-randomization=0
mode=ap
seen-bssids=
ssid=WiFi
[wifi-security]
group=
key-mgmt=wpa-psk
pairwise=
proto=rsn
psk=123456789
[ipv4]
dns-search=
method=shared
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore
Then I found a setup that somewhat worked for the ethernet ports:
[connection]
id=eth-bridge
type=ethernet
interface-name=eth0
permissions=
[ethernet]
mac-address-blacklist=
[ipv4]
dns-search=
method=shared
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore
[proxy]
Truth be told, I don’t exactly understand what this does, but it ended up with me being able to see some of the downstream devices when connected to the hotspot. However, the devices themselves did not connect to the outside world. I did have internet access through the hotspot though. It was quite strange (to me at least). It was like I was looking at the network through the eyes of my main device, not as a client connected to it.
I also noticed that in Balena Dashboard, the Raspberry Pi showed up with multiple IP addresses, presumably because of the hotspot. One IP was for the incoming internet connection, one for the Hotspot. There was also a third one in yet another subnet which I couldn’t pinpoint.
The closest I got for a similar setup was this: https://raspberrypi.stackexchange.com/a/99598
Alas, it uses systemd networking, which is different from NetworkManager, I think, so does not translate properly to Balena’s environment.
As you can probably tell, this is a mess, so I’m hoping that somebody who knows more about working with NetworkManager than me can give me some pointers on:
- How to set this up
- Whether this setup is feasible
- Whether this setup is a good idea at all or whether something else may work better
- Whether my current approach is anywhere close to going into the right direction
Have a good one, hopefully someone can help me out with this