1

I work on dual independent modem device (yocto based). I would like to assign each to a different NM connection. I register them using cmd:

nmcli c add type gsm ifname cdc-wdm[0|1] con-name mdm1orange apn internet

It works. The problem is, cdc-wdm suffix comes from device registration/turn on order. I would like to associate it with USB port (they will use different operators SIMs APNs, configs etc), so I've created an udev rule:

SUBSYSTEM=="usbmisc", SUBSYSTEMS=="usb", KERNELS=="1-1.3:1.4", SYMLINK+="modem2", TAG+="systemd"
SUBSYSTEM=="usbmisc", SUBSYSTEMS=="usb", KERNELS=="1-1.4:1.4", SYMLINK+="modem1", TAG+="systemd"

It does work, I can see /dev/modem1 and /dev/modem2 being registered, but calling:

nmcli c add type gsm ifname modem[1|2] con-name mdm1orange apn internet

Just fails. NM does not have a clue which device I would like to use in connection.

So how can I assign based-on-usb-port-alias or index (with udev or anything else) to modem network interface, not just the /dev/ symlink? It would be nice to have also a WWAN interface alias created too.

Thanks!

2 Answers 2

0

The name of a network interface is just a name, not a device node, so a symbolic link cannot point to a network device. Your udev rule generates a symlink that points to a usbmisc device, not to a network interface, so that's why it won't work.

Do the cdc-wdm network devices have any persistent attributes, like a MAC address or equivalent? If you run e.g. ethtool --show-permaddr cdc-wdm0, do you get an unique identifier that stays the same from one modem turn-on to the next? Or if you run udevadm info -q all -p /sys/class/net/cdc-wdm0, does it reveal any attributes that are both persistent from one modem turn-on to the next and unique to the individual modem?

If your yocto-based device has systemd-udevd, then you might be able to use /etc/systemd/network/*.link files to assign a persistent network interface names for your modems.

I recently used a Zyxel WAH7601, a 4G (LTE) USB modem/mobile WiFi access point. When connected over USB, it uses the rndis_host network driver, and presents a new MAC address each time it's turned on. I found that annoying with my laptop, as it caused NetworkManager to detect it as a "new" connection each time it was powered up.

The first step to fixing that was to create a persistent network device name for it. The above-mentioned udevadm info command indicated the device had a ID_SERIAL_SHORT=xxxxxxxxxxxx serial number attribute (actual S/N redacted for privacy). And that stayed the same when power-cycling the modem (as expected for a device serial number). So I created a /etc/systemd/network/72-zyxel.link file like this:

[Match]
Driver=rndis_host
Property=ID_SERIAL_SHORT=xxxxxxxxxxxx

[Link]
Description=Zyxel WAH7601
NamePolicy=
Name=zyxelmodem0

This gave me a persistent network interface name for the modem, locked on the modem's serial number. The Property= line refers to the attribute in the output of the above-mentioned udevadm info ... command that should be used to match the link file to the actual network device. The empty NamePolicy= is important, as it cancels the system-wide default NamePolicy for this device only. And the Name= line just specifies the name I wanted for the device (it will take effect only if NamePolicy is null or fails to produce a more "standard" name).

The second part of the solution for me was to create a NetworkManager connection for the modem, and then modify it to use just the device name (instead of a MAC address, since it varies for this modem) to tie the connection to a particular device:

 <creating a connection using NetworkManager GUI>
 nmcli c mod ZyxelModem connection.interface-name zyxelmodem0
 nmcli c mod ZyxelModem 802-3-ethernet.mac-address ""
2
  • "persistent network interface name for the modem" thats it! - but i will stay with USB port identification. The last one is a bit of lie, bc they use miniPCI which is the same from the system point of view, but "more internal". Nobody will physicaly plug them on or off, only power supply is under my control. I would like to have a possibility to replace the model or unit without editing the system image. I will check yout trick, thank You so much!
    – JWZ1996
    Commented Oct 6, 2022 at 21:11
  • We use externally multiplexed sim cards, sim switch requires full modem power disabling, unfortunately.
    – JWZ1996
    Commented Oct 6, 2022 at 21:21
0

So after examining, udev let us only change the name of the network interface. You cannot change the name of the file in /dev/ folder, you can just create an alias/symlink/label etc.

This (symlink or new net-dev name) did not work for ModemManager and Network manager. For MM, you can use special udev rules to identify modems in CLI. This does not work for the DBus interface though. And it does not work for NM.

I moved to qmicli and I am very happy with it ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .