Programmatically determine qmimux ifname?

For a script that I am using, I need to programmatically determine the name of the qmimuxN interface that gets assigned the IP address when using WWAN. It’s usually qmimux0 but sometimes (for reasons unknown!) it gets assigned as qmimux1.

I poked around inside /lib/netifd/netifd-proto.sh to see if I could work something out. The 2 one-liners below both “do the job” but I’m not sure if these are safe/correct. Anyone have a better way, or is this a good way of doing it?

grep -m1 qmimux /var/run/qmux/mob1s1a1.up
ubus -S call networkmap interfaces |
jsonfilter -e '@.interfaces[@.proto="wwan" && @.status=true].device'

Hi,
these commands probably would be fine, but I would suggest to interact more with netifd or API, because if something changes internally your script might get broken.
You can list network interfaces from config or in ubus:
ubus list network.interface.*
Then there is a lib at /lib/functions/network.sh, there you can find usefull functions.
OR
api get /interfaces/status
https://developers.teltonika-networks.com

I examined the JSON returned by the api but couldn’t find a way to reverse this interface name from the output. For example the JSON paths that contain the value qmimux0 are:

.http_body.data[4].ifname
.http_body.data[4].device
.http_body.data[4].l3_device

This topic was automatically closed after 15 days. New replies are no longer allowed.