Changing Network Settings via DBUS is not persistent anymore

Hi,

In our company, we deliver preloaded Edge-Devices with the BalenaOS. However we don’t know the IP-Settings of the customers, so we created a file called “resin-static-net5” in the system-connections folder on the boot partition of the flash thumb drive. Then we wrote a script that connects to NetworkManager DBUS API and let the customer change the Settings of the resin-static-net5 file (the interface is called net5) with the script. We tested it and it worked. we were able to change the settings from auto/dhcp to manual/static ip. After reboot the changed settings were still available.

However we tested it last week, and out of a sudden it is not working anymore. We are able to chage the settings over DBUS but when we reboot the device the settings are now lost.

in the Documentation the following is written:
"On device boot, the files in resin-boot/system-connections are copied into /mnt/state/root-overlay/etc/NetworkManager/system-connections"

So after i changed my settings i checked the files.
/etc/NetworkManager/system-connections/resin-static-net5 AND /resin-boot/system-connections/resin-static-net5 have been changed.
/mnt/boot/system-connections/resin-static-net5 is still the old one that we copied to the flash thumb drive.

After reboot all files are being reset to the old one that is on /mnt/boot/system-connections/resin-static-net5.

So my questions are:

  1. why did it work in the past, but now it is not working? If i understand the Documentation correct this is not the intended behavior.
  2. is there currently a solution for this problem? how can one achieve that the changed network settings with DBUS are also present after a device reboot?

Thanks a lot in advance.

currently we are using balenaOS 2.58.6+rev1 dev image

Hello, just to check that I have understood correctly -

You’ve created a custom connections file called resin-static-net5, and placed it in the boot partition. You then have a script that modifies this file - at runtime? Is this script running on the device, from a container? What does this script do exactly and how? Is this script modifying the connection resin-static-net5? Thanks!

Thanks for your Reply,

yes i placed a custom connections file called resin-static-net5 into the boot partition, but i don’t modify it at runtime.

As the Balena Docs tell, i can use the NetworkManager via DBUS in my python script. So i tell the NetworkManager via DBUS that it should change the Network settings according to my function call. NetworkManager itself is than changing the resin-static-net5 files on the system partition (and not on the boot partition)

Hello @sqaureroot

Please could you post a copy of your Python script so that we can look into this further.

Kind regards

Mark

Hi, I do not think what you described worked for you before. Files in /mnt/boot/system-connections are always copied over on reboot, so any modifications on top of them using the D-Bus API are overwritten.

If you create this profile on first boot through the D-Bus API and do not specify it in /mnt/boot/system-connections then you will not face this issue.

So on start of your application you may check whether the NetworkManager connection profile exists, and create it with default values if it is not there.

Thanks all for your help,

After testing a lot i think @majorz is right, and it has never worked before.
I wrote a Python script that’ll create the files on first boot as @majorz recommended and it works pretty well.

Good to hear that you resolved the issue.