I am trying to prevent modem manager from running when I plug my cell phone into a USB port.

I have tried to add a custom rule with udev, but my custom rules seem ignored. I created a file /etc/udev/rules.d/99-mm-usb-device-blacklist.rules which contains

# LG Phone
ATTRS{idVendor}=="1004", ENV{ID_MM_DEVICE_IGNORE}="1"

And yet when I plug in the phone and check dmesg, this is what I get:

[ 1809.761940] usb 3-1: new high-speed USB device number 11 using xhci_hcd
[ 1809.778662] usb 3-1: New USB device found, idVendor=1004, idProduct=61fc
[ 1809.778670] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1809.778674] usb 3-1: Product: B Project USB Device
[ 1809.778677] usb 3-1: Manufacturer: LG Electronics. Inc
[ 1809.778680] usb 3-1: SerialNumber: XXXXXXXXXXXXXXXXX
[ 1809.779501] cdc_acm 3-1:1.0: This device cannot do calls on its own. It is not a modem.
[ 1809.779584] cdc_acm 3-1:1.0: ttyACM0: USB ACM device
[ 1809.780899] cdc_ether 3-1:1.3 usb0: register 'cdc_ether' at usb-0000:00:14.0-1, CDC Ethernet Device, 6e:34:73:4f:68:4c
[ 1809.781454] scsi8 : usb-storage 3-1:1.5
[ 1809.807331] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[ 1809.816566] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[ 1809.816759] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready

I have also tried editing /lib/udev/rules.dev/77-mm-usb-device-blacklist.rules but this did not work either. What am I missing? What would be a helpful step in debugging this?

Update: Running udevadm info --export-db shows the udev rule is being updated. The relevant output is:

P: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.7
N: bus/usb/002/012
E: DEVNAME=/dev/bus/usb/002/012
E: DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.7
E: DEVTYPE=usb_device
E: ID_BUS=usb
E: ID_MODEL=B_Project_USB_Device
E: ID_MODEL_ENC=B\x20Project\x20USB\x20Device
E: ID_SERIAL=LG_Electronics._Inc_B_Project_USB_Device_XXXXXXXXXXXXX
E: ID_USB_INTERFACES=:020201:0a0000:ffffff:020600:080650:
E: ID_VENDOR=LG_Electronics._Inc
E: ID_VENDOR_ENC=LG\x20Electronics.\x20Inc
E: MAJOR=189
E: MINOR=139
E: PRODUCT=1004/61fc/216
E: TYPE=239/2/1

So modem manager should be ignoring the device. And yet my computer keeps trying to initialize a network connect through my phone whenever I plug it to the USB port. Is there another program that udev is launching?

  • 1
    Did you run ModemManager --debug to check what it was doing with the device in question? I'm also slightly surprised to not see ID_MM_CANDIDATE=1 in that entry -- perhaps this is a separate codepath scanning devices in ModemManager which doesn't respect that attribute? – kiko Nov 17 '18 at 19:24
  • @kiko, I have the same issue as the question author. ID_MM_CANDIDATE does not appear in the USB device output, but there is a separate entry in the database output for the TTY device, and this has both ID_MM_CANDIDATE=1 and ID_MM_DEVICE_IGNORE=1. Modem Manager debug logs show that it is indeed probing the device. – Ian Mackinnon Feb 19 at 9:23

While there may be a way to do this with udev, I found a much simpler working solution at this AskUbuntu question.

To summarize, you can tell Network Manager not to manage certain devices by adding a line to its .conf file.

First, find your cell phone's mac address. Run dmesg from the terminal after you plug it in; one of the print outs should have the mac. The line for me was:

[ 4691.112016] cdc_ether 3-1:1.3 usb0: register 'cdc_ether' at usb-0000:00:14.0-1, CDC Ethernet Device, de:1a:28:c7:db:e6

Next, open /etc/NetworkManager/NetworkManager.conf with super user privledges, and add a your phone's mac as an unmanaged device. This is my NetworkManager.conf; I added the last two lines.




Modem Manager can be configured to use different filter policies, and the udev tags such as ID_MM_DEVICE_IGNORE have no effect under the strict filter policy.

You can determine which policy Modem Manager is using on your system by viewing its status:

> sudo systemctl status ModemManager
● ModemManager.service - Modem Manager
   Loaded: loaded (/lib/systemd/system/ModemManager.service...
   Active: active (running) since ...
   CGroup: /system.slice/ModemManager.service
           └─644 /usr/sbin/ModemManager --filter-policy=strict

This also shows that the relevant service file is /lib/systemd/system/ModemManager.service. We can edit this file in different ways to disable probing of a particular device.

To use a different policy which will refer to the udev blacklist rules we can change the command in the service:

ExecStart=/usr/sbin/ModemManager --filter-policy=default

Options are default (just use the blacklist rules) or paranoid (like strict but also use the blacklist rules). The documentation mentions this is not recommended as support for blacklist rules may be obsoleted in the future.

Another option is to filter a class of devices using one of several TTY-specific environment variables. This can be achieved by appending a line to the [Service] section of the service file. For example, to prohibit probing of ACM TTY devices:


After changing the service file, reload the systemctl configuration and restart ModemManager:

sudo systemctl daemon-reload
sudo systemctl restart ModemManager

For debugging purposes it may be useful to watch modem manager logs when connecting your device. To enable debug logging, run:

sudo mmcli -G DEBUG;

To watch the filter log messages, run:

journalctl -f | grep "ModemManager.*\[filter\]"

Now when you connect your device you should see lines like:

# Device allowed with strict filter policy
[filter] (tty/...): port allowed:... 

# Device filtered with default filter policy and udev tags
[filter] (tty/...): port filtered: device is blacklisted

# Device filtered with strict filter policy and environment variables
[filter] (tty/...) port filtered: forbidden

To return ModemManager logging to its prior state, run:

sudo mmcli -G ERR

(just for sake of science, since you have already solved your issue...)

udev reads/executes its rules in the alphabetical order[1].
This could mean that your settings should be overwritten be NetworkManager, that's your rule is useless.

If you rename your rule from 99- to 99999- does this change help you?

[1] https://unix.stackexchange.com/questions/204979/why-do-the-rules-in-udev-rules-d-have-numbers-in-front-of-them

  • I had this problem 5 years ago, and no longer have any of the hardware which I experienced the issue with. I seem to recall messing with the filenames, but can't recall the exact circumstances. – superdesk Feb 26 at 14:27

This site is temporarily in read only mode and not accepting new answers.

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