0

For experimentation purposes I have bought some pairs of wifi and bluetooth devices and I plan to get some more.

However when two or more of the same type are plugged in to the hub lsusb lists multiple instances of the device.

Eg. a Realtek wifi adapter as the USB id 0bda:f179. If there are 3 of them this id will appear 3 times.

What means of has Linux got for identifying them uniquely, not just when they are plugged in the same machine, but in other machines as well?

Network adapters for instance have their MAC address stamped on them, and USB disk drivers also have some IDs linked with them, but I don't know about these wireless dongles and bluetooth devices.

I would expect it to be their MAC addresses but in the wireless adapters it was always different when they connected to my access point, and even in the ifconfig listing. I suspect Linux was giving them new MACs each time, unless it was the devices themselves.

Does the USB standard specify away for identifying each device uniquely, regardless of what type it is?

2 Answers 2

1

In Linux, you can use the udev system to assign unique identifiers to USB devices based on various criteria such as the device's vendor and product IDs, its serial number, or its physical location on the system's USB bus. This allows you to uniquely identify devices even if they have the same USB ID.

To find the MAC address of a wireless network adapter, you can use the ip or ifconfig command. However, as you have noted, the MAC address may change depending on the network to which the device is connected. This is because some wireless adapters use randomized MAC addresses for privacy reasons.

Bluetooth devices also have unique identifiers called Bluetooth device addresses (BD_ADDRs), which are similar to MAC addresses. You can use the hcitool or bluetoothctl command to view the BD_ADDR of a Bluetooth device.

Regarding the USB standard, it does specify a unique serial number for USB devices, but not all devices have one. If a device does have a serial number, you can use it to uniquely identify the device. However, if the device doesn't have a serial number, you can still use other criteria such as the vendor and product IDs to differentiate it from other devices with the same USB ID.

1
  • How can I enumerate the list of ids udev has assigned to plugged in devices?
    – vfclists
    Commented May 13, 2023 at 22:15
1

I think you've answered your own question - Linux DOES keep track of them - the USB id is not a unique identifier, it identifies the type of device. Its not uncommon to have multiples of the same device plugged into a host when it comes to disk drives and network cards. The kernel first enumerates the devices (based on the order of discovery) and applies an internal naming scheme based on the type of device and the order of discovery then udev may apply an alternate naming system (typically to make device names persistent regardless of the order they were discovered in).

Typically swapping the physical attachment of 2 devices of the same class of device, will cause the kernel assigned names to be swapped.

If the device type has unique characteristics known to the kernel (see udevinfo) then you can configure udev to apply alternate names based on matching these attributes. Most devices expose a serial number. Udev can also run an external program to discover additional attrbutes at run time to match - see also https://www.reactivated.net/writing_udev_rules.html

You must log in to answer this question.

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