1

I'd like my computer to automatically connect to my vpn whenever I tether to my phone. The problem is that the connection gets assigned a new MAC address and name every time I connect.

A few years ago I managed to fix this using a udev rule but I've been trying for days and I can't figure out how I did it before.

Would someone please help me write a udev rule or find an alternative solution?

Here's udevadm info -a -p $(udevadm info -q path -n /dev/bus/usb/003/009)

looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-3':
KERNEL=="3-3"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{authorized}=="1"
ATTR{avoid_reset_quirk}=="0"
ATTR{bConfigurationValue}=="1"
ATTR{bDeviceClass}=="e0"
ATTR{bDeviceProtocol}=="00"
ATTR{bDeviceSubClass}=="00"
ATTR{bMaxPacketSize0}=="64"
ATTR{bMaxPower}=="96mA"
ATTR{bNumConfigurations}=="1"
ATTR{bNumInterfaces}==" 3"
ATTR{bcdDevice}=="0226"
ATTR{bmAttributes}=="c0"
ATTR{busnum}=="3"
ATTR{configuration}==""
ATTR{devnum}=="9"
ATTR{devpath}=="3"
ATTR{idProduct}=="6864"
ATTR{idVendor}=="04e8"
ATTR{ltm_capable}=="no"
ATTR{manufacturer}=="samsung"
ATTR{maxchild}=="0"
ATTR{product}=="GT-I9305"
ATTR{quirks}=="0x0"
ATTR{removable}=="removable"
ATTR{speed}=="480"
ATTR{urbnum}=="773"
ATTR{version}==" 2.00"

and here's some of udevadm info -q all -n /dev/bus/usb/003/009

P: /devices/pci0000:00/0000:00:14.0/usb3/3-3
N: bus/usb/003/009
E: DEVTYPE=usb_device
E: DRIVER=usb
E: ID_BUS=usb
E: ID_MODEL=GT-I9305
E: ID_MODEL_ENC=GT-I9305
E: ID_MODEL_FROM_DATABASE=GT-I9070 (network tethering, USB debugging enabled)
E: ID_MODEL_ID=6864
E: ID_REVISION=0226
E: ID_USB_INTERFACES=:e00103:0a0000:ff4201:
E: ID_VENDOR=samsung
E: ID_VENDOR_ENC=samsung
E: ID_VENDOR_FROM_DATABASE=Samsung Electronics Co., Ltd
E: ID_VENDOR_ID=04e8
E: MAJOR=189
E: MINOR=264
E: PRODUCT=4e8/6864/226
E: SUBSYSTEM=usb
E: USEC_INITIALIZED=1914672992

Finally, when I activate usb tethering, udevadm monitor gives me

   UDEV  [3129.357001] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.1 (usb)
   UDEV  [3129.389973] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/net/enp0s20u3 (net)
   UDEV  [3129.393191] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/net/usb0/queues/rx-0 (queues)
   UDEV  [3129.393625] add      /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/net/usb0/queues/tx-0 (queues)
   UDEV  [3129.394565] move     /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/net/enp0s20u3 (net)

I've tried various rules for 70-persistent-net.rules and my current is

    SUBSYSTEM=="net", KERNEL=="enp0s20u3", ACTION=="add", ATTR{address}="4A:9E:C3:67:F4:1D" NAME="Phone"

Which doesn't work.

2 Answers 2

1

Had a similar/related problem with connecting/tethering the phone. The route metric would be higher that the wired ethernet being "100", and the wired ethernet had no Internet connection.

The phone USB connection would have a metric of "101" so no connection to the internet via the phone, as the lower metric default gateway is the selected path. So, I rename the connection to PhoneTether and set device, as above, to DEVICE, as per:

nmcli -t --fields NAME,TYPE,DEVICE connection show --active

and then set the profile metric to "99", as below:

nmcli conn mod id PhoneTether ipv4.route-metric 99

Now when i plug in the phone, the route metric is 99 and thus the preferred Default route. When I unplug the phone, back to normal.

0

To answer my own question, I didn't need to do any of this. In 16.04 network manager, edit the connection and in the device field, type the name (in this case enp0s20u3) instead of the MAC address. Deselect 'make available to all users' to make it automatically reconnect. - maybe a bug?

You must log in to answer this question.

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