# Giving my USB router a fixed interface name



## yha (Aug 15, 2021)

Hello,

      I have a NETGEAR Nighthawk M5 wireless router (which can also do USB tethering), and it normally shows up as "ue0" when I connect it to a USB port on my laptop. However, when I dock my machine at the office, ue0 becomes the docking station's ethernet interface, and the router shows up as ue1 (in fact, I'm not sure if it is always in this order, but in any case, all my rc.conf configs referring to ue0 are no longer guaranteed to "point" to the router).

How do I fix the router as "ue0", and the docking station's interface as "ue1"? I suppose this can be done with devd, but I'm not sure how...


----------



## Tieks (Aug 15, 2021)

The Realtek device that was attached first will show up as "re0", the second one as "re1". So likely both router and docking station can show up as either "re0" or "re1". Then /etc/rc.conf will only work if both interfaces can use DHCP, which is probably not the case.
You can indeed use devd to solve this by adding a .conf file for both in /usr/local/etc/devd. Identify the devices by vendor id and product id and select the devd events you need to bring that interface up and down again. In a case like that I start with something like this in /usr/local/etc/devd/new_usb_device.conf:

```
notify 900 {
    match "system"      "USB";
    match "type"        "ATTACH";
    match "vendor"      "0x1234";  (your vendor/product id's here, see usbconfig)
    match "product"     "0x5678";
    action "logger attach: 1-$device 2-$devclass 3-$devsubclass 4-$interface 5-$intclass 6-$intprotocol 7-$mode 8-$notify 9-$cdev";
};

notify 900 {
    match "system"      "USB";
    match "type"        "DETACH";
    match "vendor"      "01234";  (your vendor/product id's here, see usbconfig)
    match "product"     "05678";
    action "logger detach: 1-$device 2-$devclass 3-$devsubclass 4-$interface 5-$intclass 6-$intprotocol 7-$mode 8-$notify 9-$cdev";
};
```

After `service devd restart` connecting and disconnecting the device will give you lines in /var/log/messages. Add match lines until only the events needed remain. As the final step replace the action line with the commands needed to bring the interface up and down (after you removed the lines from rc.conf). See `man devd.conf` for details.


----------

