Adding SLIP networking to Balena

I’m trying to add a SLIP networking interface to Balena. It’s working-ish as-in, when manually logging into a balena container with local mode. I can type all the commands and get it setup. However when it’s executing the same commands from a script (or via Docker RUN’s) the SLIP interface is not able to ping the other side.

Since i’m new to Balena, I only just figured that Networking should be done from the host it self, and that I should be adding a config file into the boot partition’s system-connections directory.

However I can’t find anything about SLIP support for Network Manager. Anyone that can perhaps point me in the right direction? Should I pursue getting the networking running from within the container, or figure out how to make it work from the balena host (supervisor) ?

Hi Steven, welcome to the forums!

If you can already set it up from within a container then you should definitely be able to automate that via a script. Can you share the commands you are using and how you are running the script?

Regarding networking in general, we allow both approaches in balenaOS, you can configure networking at runtime from a container (via DBUS or nmcli for instance) but we also allow configuration via system-connections directory. I’m not very familiar with SLIP, but I understand it should have support built in (also seeing as you can get it to work manually).

Also, if you haven’t, take a look at our docs which cover some of this topics:

If you can share further details on the scripts and commands you are running we can provide more assistance.

Hey tmigone, thanks a lot for the quick response!

In my Dockerfile.template i’ve got

FROM balenalib/%%RESIN_MACHINE_NAME%%-debian
ENV UDEV=on
CMD [ "./start.sh" ]

And the start.sh contains:

echo "Loading slip module"
modprobe slip
echo "Attaching to slip interface"
slattach -d -v -L -s 115200 -p slip /dev/ttyACM0 &
sleep 10
echo "Configuring slip interface"
ifconfig sl0 172.16.0.1 pointopoint 172.16.0.2
ifconfig sl0 mtu 600

Now in between reboots, sometimes it’s working and the other times i’m not able to ping my point to point ip address: 172.16.0.2.

Maybe i’m doing something wrong with using my /dev/ttyACM0. I was reading your medium blog post about Balena and udev, that was a huge help this morning. Great article :slight_smile:

Thanks Steven, I’m glad you found it useful!
In the cases it is failing, can you verify if device /dev/ttyAMC0 is actually present in the container? Also, can you check /var/log/messages and dmesg for slattach related errors? That might shed some light. By the looks of it, the issue occurs when attaching the interface and not when doing the network configuration, though I might be wrong.

Sorry for the late reply, but for some reason i’m not able to get it to stop working today. So I can’t debug. I will post en update when it stops working again so I can do some more debugging.

Hi, NetworkManager does not provide any SLIP support indeed.

Could it be that you do not have a sleep after the modeproble - by looking at the script above it is worth adding some there to see if it will help. Once you reproduce the issue again, please take a look for logs from the kernel with dmesg.

Since it is sometimes working/sometimes not working, you may consider implementing a strategy to bring it up if it stops working, e.g. monitoring this in a loop and issuing recovery commands. This is in case it is not an obvious error which could be resolved more easily.

Thanks,
Zahari

Hey @majorz I think your right, that a sleep 10 fixes things! awesome thanks! :wink: