3

Is there a way to prevent network manager from auto-connecting to new RNDIS devices?

Android RNDIS devices cannot be configured using Network Manager because they connect with a random MAC address. This means that next time you plug the device in, it has a different MAC and Interface name, and will no longer be associated with any profile you previously set up in Network Manager.

So instead, I use udev, like so

ACTION=="move", SUBSYSTEM=="net", ATTRS{serial}=="xyz", RUN += "/etc/udev/scripts/myudevscript %k"

The script reads

/sbin/ifconfig $1 down >> /var/log/udevtest 2>&1
/sbin/ip link set $1 address 02:11:22:33:44:55 >> /var/log/udevtest 2>&1
/sbin/ifconfig $1 192.168.42.10/24 >> /var/log/udevtest 2>&1
echo nameserver 127.0.0.1 > /etc/resolv.conf # I run bind locally
systemctl stop openvpn@direct # Stop the VPN that doesn't use my phone
systemctl start openvpn@clientvpn2 # Start the one that does

It all works but only when NM is turned off. If NM is enabled, we usually get a device busy error, since two things are trying to configure it at once. I would like, if possible, not to have to disable NM as I use it for other connections.

As you can see my script forces the MAC address, but unfortunately NM has already got to work by then, based on the random MAC.

If there is a solution which as a side-effect prevents auto-connect to previously unseen Wifi networks then that would be a bonus!

Rodney
  • 140
  • 8

0 Answers0