I have a dlink DW-157 3g dongle. I am trying to assign the same port to the dongle everytime it boots up by modifying the udev rules file. Since the dongle on boot boots up as a storage media, I have to enter the command below to eject and mount for modem mode and then other command below it to make use of the ttyUSB ports of the modem for running a dial up modem.

sudo eject /dev/sr0
sudo /bin/sh -c "echo 2001 7d0e > /sys/bus/usb-serial/drivers/option1/new_id

After entering these, sudo dmesg| grep ttyUSB appears as:

[   17.581264] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB1
[   17.584470] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB2
[   17.593854] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB3
[   17.594869] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB4

The actual port on which I can use the modem for dial up is ttyUSB1. So, I'm trying to assign ttyUSB1 to d_uart in my udev rules file:

ACTION=="add", ATTRS{idVendor}=="2001", ATTRS{idProduct}=="7d0e", SYMLINK+="d_uart"

But what happens is d_uart gets assigned to ttyUSB4. What do I do to assign it to the first port always (ttyUSB1 in this case) ?

Also, the output of the command for ttyUSB1,ttyUSB2,ttyUSB3 and ttyUSB4 for the comnand below:

udevadm info -a -n /dev/ttyUSB4 | grep '{serial}' | head -n1

is the same.


Also, output of command ls -l /dev/d_uart

lrwxrwxrwx 1 root root 7 Oct  3 13:27 /dev/d_uart -> ttyUSB4

lsusb output:

Bus 001 Device 006: ID 2001:7d0e D-Link Corp.
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root h

Output of udevadm info -n /dev/ttyUSB2:

P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.3/ttyUSB2/tty/ttyUSB2
N: ttyUSB2
S: d_uart
S: serial/by-id/usb-D-Link_Inc_D-Link_DWM-157-if03-port0
S: serial/by-path/platform-3f980000.usb-usb-0:1.4:1.3-port0
E: DEVLINKS=/dev/d_uart /dev/serial/by-id/usb-D-Link_Inc_D-Link_DWM-157-if03-port0 /dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.3-port0
E: DEVNAME=/dev/ttyUSB2
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.3/ttyUSB2/tty/ttyUSB2
E: ID_BUS=usb
E: ID_MODEL=D-Link_DWM-157
E: ID_MODEL_ENC=D-Link\x20DWM-157
E: ID_PATH=platform-3f980000.usb-usb-0:1.4:1.3
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_4_1_3
E: ID_SERIAL=D-Link_Inc_D-Link_DWM-157
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Miscellaneous Device
E: ID_USB_INTERFACES=:020e00:0a0002:ff0201:ff0000:080650:
E: ID_VENDOR_ENC=D-Link\x2cInc\x20\x20
E: MAJOR=188
E: TAGS=:systemd:
  • Add the lsusb outputto your post please
    – Serge
    Commented Oct 3, 2016 at 12:58
  • @Serge Added it.
    – bobdxcool
    Commented Oct 3, 2016 at 19:31
  • lsusb does not help much in your case unfortunately. would you mind to add ` udevadm info -n` for all other serial ports of that device?
    – Serge
    Commented Oct 5, 2016 at 12:00

1 Answer 1


You can try to match on the creation of the ttyUSB1 device. Change your rule to

ACTION=="add", ENV{ID_VENDOR_ID}=="2001", ENV{ID_MODEL_ID}=="7d0e", ENV{DEVNAME}=="/dev/ttyUSB1", SYMLINK+="d_uart"

Make sure you do sudo udevadm control --reload after any changes. You should probably be matching on the ID_USB_INTERFACE_NUM, if this differs for each port, so that it works even if you have other ttyUSB* devices.

  • How do I get , ID_USB_INTERFACE_NUM ? And also how do I add that field in the rules file ?
    – bobdxcool
    Commented Oct 3, 2016 at 19:28
  • It should be in the output of udevadm info -n /dev/ttyUSB4
    – meuh
    Commented Oct 3, 2016 at 19:31
  • And also how do I add that field (ID_USB_INTERFACE_NUM) in the rules file that you posted above ?
    – bobdxcool
    Commented Oct 3, 2016 at 19:33
  • udevadm info prefixes the value with E: so it is found in the environment ENV{} like ID_VENDOR_ID.
    – meuh
    Commented Oct 3, 2016 at 19:37
  • I see that ID_USB_INTERFACE_NUM is different for different USB devices. But my question is in case the modem gets assigned from ttyUSB5 to ttyUSB9 instead of ttyUSB1 to ttyUSB4, will ID_USB_INTERFACE_NUM remain the same or change ?
    – bobdxcool
    Commented Oct 3, 2016 at 19:47

You must log in to answer this question.

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