usbip
Share USB devices over a network
TLDR
List all local USB devices and their bus ID's
Start a usbip daemon on the server
Bind a USB device to usbip on the server
Load the kernel module required by usbip on the client
Attach to the usbip device on the client (bus ID is the same as on the server)
List attached devices
Detach from a device
Unbind a device
SYNOPSIS
usbip [OPTIONS] <subcommand> [ARGS]
Common subcommands and their usage:
usbip list [-l | -r <host> [--tcp-port=<port>]]
usbip bind -b <busid>
usbip unbind -b <busid>
usbip attach -h <host> -b <busid> [--tcp-port=<port>]
usbip detach -p <port>
usbip port
usbip version
usbip help
PARAMETERS
-l, --local
Used with usbip list to display local USB devices available for binding.
-r <host>, --remote=<host>
Used with usbip list to display USB devices exported by a specified remote host (by hostname or IP address).
-b <busid>, --busid=<busid>
Specifies the bus ID of a USB device, e.g., '1-1' or '2-2.1'. Required for bind, unbind, and attach operations.
-h <host>, --host=<host>
Specifies the hostname or IP address of the remote server. Required for usbip attach.
-p <port>, --port=<port>
Specifies the port ID of a virtual host controller to which a device is attached. Required for usbip detach.
--tcp-port=<port>
Allows specifying a custom TCP port number for usbip communication, overriding the default port 3240. Used with list -r and attach.
-D, --debug
Enables verbose debug output to stderr, useful for troubleshooting.
--dmesg
Prints kernel messages related to usbip operations, often providing more context on device interactions.
-v, --version
Displays the current version information of the usbip utility.
DESCRIPTION
usbip is a Linux command-line tool that enables the sharing of USB devices over an IP network. It allows a client machine to use a USB device physically connected to a remote server as if it were directly attached locally. This functionality is achieved by creating a virtual USB host controller on the client and tunneling USB requests across the network. It's particularly useful for virtual machine environments, remote development setups, or when needing to share specialized USB hardware without physical proximity.
The process generally involves two main steps: first, on the server, the desired USB device is bound to the usbip-host kernel driver, making it available for network export. Second, on the client, the remote device is attached to a local virtual host controller, specifically the vhci-hcd driver, which then presents it as a local USB device to the operating system.
CAVEATS
Kernel Modules: Requires specific kernel modules (usbip-core, usbip-host, vhci-hcd) to be loaded on both server and client.
Performance: Network latency and bandwidth directly impact performance, especially for high-throughput devices like storage or webcams.
Compatibility: Not all USB devices work perfectly. Complex devices or those with strict timing requirements may experience issues or fail to function.
Security: Exposing USB devices over the network can introduce security risks if not properly secured with firewalls or VPNs.
Single Client: Only one client can attach a specific USB device at a time.
CLIENT-SERVER MODEL
usbip operates using a client-server model. On the server side, the machine with the physical USB device uses usbip bind (or the usbipd daemon) to export the device, making it available over the network. On the client side, usbip attach is used to connect to the remote device, which then appears as a locally attached USB device to the client's operating system via a virtual host controller.
KERNEL MODULES EXPLAINED
The functionality of usbip relies heavily on specific Linux kernel modules:
usbip-core: The core framework for USB over IP.
usbip-host: Loaded on the server, this module makes physical USB devices exportable over the network.
vhci-hcd (Virtual Host Controller Interface Host Controller Driver): Loaded on the client, this module creates a virtual USB host controller that allows remote USB devices to be attached and appear as local devices.
HISTORY
The usbip project emerged from efforts to provide a flexible framework for network-attached USB devices within the Linux ecosystem. It originated from the Linux Foundation's Virtual USB project and has since been integrated into the Linux kernel and user-space tools. Its development has focused on improving stability, performance, and compatibility with various USB device types over time, making it a robust solution for remote USB access.
SEE ALSO
lsusb(8), modprobe(8), ip(8), firewall-cmd(1)