Hey,

> I need some help in establishing simultaneous interfaces to multiple APNs.
>
> I have an Ubuntu 20.04 system with a single cellular modem attached via USB 
> in an IoT application. My problem is that I need to drive traffic through two 
> different APNs when registered to the same cellular network. Each APN serves 
> a different purpose -- different services with different billing are to occur 
> on each.
>
> I've tried multiple ways to do this. While I can get connected with two APNs, 
> I can only get an interface name for one of the connections. I need a 
> separate interface name for each so that I can place the respective flow of 
> traffic through the appropriate interface and onto the correct APN. My 
> application needs both to be available simultaneously. Going back and forth 
> between building up and tearing down each of them is not an acceptable 
> solution.
>
> I tried three different things and none have brought happiness:
>
> (1) Using mmcli in debug mode with a set of AT commands for each APN: using 
> the sequence AT+GDCONT, AT+XGAUTH, and AT+CGACT with parameters relevant for 
> the first APN and then again with the sequence AT+GDCONT, AT+XGAUTH, and 
> AT+CGACT for the second APN. This is successful, and I obtain assigned IP 
> addresses for each APN. However, neither of the APNs are assigned to an 
> interface and I don't know how to funnel traffic to each.
>
> (2) I have used the bearer features of mmcli. I have run "mmcli -m 
> <modem-number> --create-bearer=<key-value pairs>" two times, each with the 
> proper key-value pairs for the respective APNs. When I later run "mmcli -m 
> <modem_number>", I see both bearers. I then run "mmcli -m <modem-number> 
> --bearer <bearer-number> --connect". This works the first time for the first 
> APN/bearer, and I have an interface assigned. But I get the following error 
> when next running " mmcli -m <modem-number> --bearer <bearer-number> 
> --connect" for the second APN/bearer:
> error: couldn't connect the bearer: 'GDBusError: 
> org.freedesktop.ModemManager1.Error.Core.NotFound: No valid data port to 
> launch connection'
>
> (3) I've put multiple connection keyfiles in the 
> /etc/NetworkManager/system-connections directory. I run "nmcli con reload" 
> and then "nmcli --wait 120 con up id <name_of_first_connection>". This works 
> as I get connected to the first APN, get assigned an IP address, and get an 
> interface association (wwan0). However, when I run "nmcli --wait 120 con up 
> id <name_of_second_connection>", this works, but it displaces the first 
> connection, so I am only left with the second connection on interface wwan0. 
> The first connection is no longer available.
>
> My Ubuntu 20.04 system has mmcli 1.16.6 and nmcli 1.22.10. I could also 
> install mbimcli 1.24.8, although it is not currently part of the system image.
>
> Ideas on how to accomplish what I am after?

Your modem needs to be QMI or MBIM based, and you need to install
ModemManager 1.18, which is the first version supporting multiplexing.
Once you have that, you can:
 *  run Modem.SimpleConnect() with"multiplex=required"
Or:
 * start the ModemManager daemon with the additional
--test-multiplex-requested option.

My suggestion is to use the 2nd option, just start MM with
--test-multiplex-requested so that any attempt to start a connection
(e.g. via NetworkManager) will trigger the multiplex setup. When
running with multiplex enabled, ModemManager will create a new virtual
network interface for each APN connection, and then you can handle
custom routing rules in the host for each of them.

I talked a bit about this feature in the FOSDEM2022 talk earlier this
year, if you're interested:
https://fosdem.org/2022/schedule/event/mobile_modemmanager/

-- 
Aleksander
https://aleksander.es

Reply via email to