Cellular/LTE modem - automatic APN configuration

We’re using LTE on most of our devices and so far we always configured the APN settings fixed in a NetworkManager config file. However there are cases when we ship the devices abroad a the client installs a local SIM card. Ofc we can get the device online via LAN/WiFi and configure the APN manually but that is in practice not always so easy because of communication with the client, technical understanding, company networks behind a firewall etc.
Therefore it’d be perfect if the correct APN settings were detected automatically, like it is done on Android and many LTE gateways (e.g. Teltonika). From my understanding neither NetworkManager nor ModemManager nor any other tool in the HostOS is capable of that - correct?
The only way I’d see then would be to write our own APN manager inside a container and modify the connections in the HostOS via dbus. Has anybody done something like that before? Any tips or recommendations?


I’ve ran into this issue before, and the way I overcame it was to use Andriod’s open-source apns database here.

You can then create a parser class/ library to parse the XML file and get the APN that you need based on the SIM’s MCC and MNC.

It doesn’t contain all possible APNs, but it was sufficient for us. It also allows you to add new ones to the database if need be.


One thing you could test, would be enabling auto-config key in the cellular config file.

Key: auto-config
Default: FALSE
When TRUE, the settings such as APN, username, or password will default to values that match the network the modem will register to in the Mobile Broadband Provider database.


1 Like

Hello @Hesch

there is information on how to setup cellular modem on balena with NetworkManager here

We recorded a video some time ago and you can find some ideas here

Let us know if this works!

This doesn’t help with the automatic APN configuration, which is a large downside of the config setup, imho.

Hello @danedwards_ee when no APN is specified ModemManager will retrieve an APN automatically.

Different APNs that are provided by the network usually correspond to different ipv4/ipv6 combinations - like one enabled with ipv4, but not ipv6, or one with both ipv4 and ipv6 enabled.So depending on whether ipv6 is enabled in the NetworkManager connection profile or not enabled a different APN could be picked up automatically.

If you still cannot get connectivity with ModemManager, but get one with a Teltonika gateway, could you please confirm the ModemManager version do they use? do you think you can share ModemManager logs? I also think it might be interesting to connect with ModemManager maintainers.

1 Like

Thank you for all the comments! We tried them out and found the following:

  • leaving apn just empty works
  • settings auto-config=true doesn’t work, because NetworkManager can’t find the xml file it’s looking for (/usr/share/mobile-broadband-provider-info/serviceproviders.xml)

First of all it’s very nice to see that just leaving the apn blank is apparently enough to solve our issue. I’m a bit surprised though that this works - is this a new feature? It seems to be little known or I missed it before. We’d like to increase our understanding of how things are working. Especially we’re currently trying to figure out

  • How does the modem/NetworkManager acquire the APN when it’s blank in the config?
  • Why is the XML file not present in Balena’s NetworkManager leading to auto-config=true to fail?
  • What are the limitations of configuring with a blank APN? Should this work in all countries with all providers or is there a certain list?