Specifically to V2+. When combined with configuring a DNS server, FTP, or SMB (for example), this is a powerful way to extend the capabilities of PiKVM.
TL;DR: By default, you can add only one additional device to choose from, such as USB Ethernet, or USB Serial, or an extra Mass Storage Drive.
There is a hardware limit on the number of devices that can be emulated at the same time. Each USB device uses so-called endpoints to communicate with the host. Depending on the type, the device consumes a different number of endpoints, while their total number is limited by the capabilities of the chip, for Raspberry Pi it is 8.
It is quite difficult to calculate the number of endpoints used, but in the case of PiKVM, you can focus on the following numbers:
|Keyboard, mouse||1 for each|
|Mass Storage Drive||2 for each|
|USB Ethernet, USB Serial||3 for each|
V2 and V3 emulates one mouse by default, V4 emulates two mouses. Thus, V2 and V3 use 4 endpoints, and V4 uses 5 by default.
Creating an axtra Mass Storage Drive consumes additional endpoints, as well as USB Serial and USB Ethernet, so only a limited number of devices can be selected for the final configuration, for example, one USB Ethernet.
If you need something more non-standard, you can disable the regular Mass Storage Drive and the additional mouse (on V4) to free up some extra endpoints.
kvmd-otg service is responsible for setting up USB emulation. If the endpoint limit is exceeded,
the service will not be able to start and no emulated USB device will work.
In the log it looks something like this:
# journalctl -u kvmd-otg ... kvmd-otg: kvmd.apps.otg INFO --- ===== Preparing complete ===== kvmd-otg: kvmd.apps.otg INFO --- Enabling the gadget ... kvmd-otg: kvmd.apps.otg INFO --- WRITE --- /sys/kernel/config/usb_gadget/kvmd/UDC kvmd-otg: OSError: [Errno 524] Unknown error 524 kvmd-otg: During handling of the above exception, another exception occurred: kvmd-otg: Traceback (most recent call last): kvmd-otg: File "/usr/bin/kvmd-otg", line 9, in <module> kvmd-otg: main() kvmd-otg: File "/usr/lib/python3.10/site-packages/kvmd/apps/otg/__init__.py", line 348, in main kvmd-otg: options.cmd(config) kvmd-otg: File "/usr/lib/python3.10/site-packages/kvmd/apps/otg/__init__.py", line 278, in _cmd_start kvmd-otg: _write(join(gadget_path, "UDC"), udc) kvmd-otg: File "/usr/lib/python3.10/site-packages/kvmd/apps/otg/__init__.py", line 83, in _write kvmd-otg: with open(path, "w") as file: kvmd-otg: OSError: [Errno 524] Unknown error 524 systemd: kvmd-otg.service: Main process exited, code=exited, status=1/FAILURE systemd: kvmd-otg.service: Failed with result 'exit-code'. systemd: Failed to start PiKVM - OTG setup.
In this case, you need to disable some of the previously enabled devices and restart PiKVM.
/etc/kvmd/override.yamland add these lines:
otg: devices: ethernet: enabled: true driver: ecm host_mac: 48:6f:73:74:50:43 kvm_mac: 42:61:64:55:53:42
host_macaddress will be used on the server's network interface. The
kvm_macmeans the address that will be assigned to the local interface on the PiKVM. The KVM interface will be called
usb0network interface. If the
kvm_macis not specified, a random value will be used. The
driverparameter means the protocol that will be used for the USB network. The default value is
ecmso it can be passed it this example. Other possible values are
Driver Operating System ecm Linux
eem Linux rndis5 Windows XP to Windows 71
Linux > 2.6.13
rndis Windows 7 and later2
Linux > 2.6.13
ncm Windows 10 and later
Linux > 2.6.37
1: Manual driver installation is required. Download RNDIS 5 Windows
2: Automatic driver installation since kvmd-3.53
To automatically configure the USB network on the server recommended using the service
kvmd-otgnet. It configures the firewall, assigns an address to the local PiKVM interface
usb0and starts DHCP so the managed server can get the IPv4 address. By default, the address
usb0will be assigned. One of the other addresses from the network
169.254.0.0./28will be assigned to the server when it requests it via DHCP. For security reasons, all incoming connections from the server to the PiKVM side are blocked (except for ICMP and UDP port 67 which is used for DHCP). If you want to allow access from the server to the PiKVM interface, then you need to add ports 80 and 443 to the whitelist using
/etc/kvmd/override.yamlfile like this:
otgnet: firewall: allow_tcp: [80, 443]
To view other available configuration parameters, use the command
To enable the service, use the command
systemctl enable kvmd-otgnet.
Routing via PiKVM¶
kvmd-otgnet will configure network connection between PiKVM and the server host only. The server host will not be able to reach other hosts beyond PiKVM. If the full network access is required from the server host through the USB-Ethernet feature (access all hosts PiKVM can access), additional settings are needed in
echo "net.ipv4.ip_forward = 1" > /etc/sysctl.d/99-kvmd-extra.conf.
Add network interface to forward requests to (default gateway) by adding a line
forward_iface: <interface name>under
firewall:. Typically it would be
eth0if the built-in ethernet port is used::
otgnet: firewall: forward_iface: eth0
Add DNS server to provide host name resolution service. For example, adding
220.127.116.11as DNS server requires addition of
dnsmasqdhcp options. This can be done by adding following lines to
otgnet: commands: post_start_cmd_append: - "--dhcp-option=6,18.104.22.168"
Combining above two together::5. To enable internet access for the server host, add the following to the otgnet configuration::
otgnet: firewall: forward_iface: eth0 commands: post_start_cmd_append: - "--dhcp-option=6,22.214.171.124"The 'net' parameter defines the network address range of the usb0 network. The server host will automatically receive an IP address within this network including the DNS servers defined under 'post_start_cmd_append'. Note: This network should not be same as the network PiKVM is connected to.
otgnet: iface: net: 10.65.0.0/28
Don't forget to
An example of what the config would look like for a server host that can access PiKVM and has internet access:
otgnet: firewall: allow_tcp: [80, 443] forward_iface: wlan0 commands: post_start_cmd_append: - "--dhcp-option=6,126.96.36.199,188.8.131.52" iface: ip_cmd: - /usr/bin/ip net: 10.65.0.0/28
Working with Windows Computers¶
This has been proven to work with Windows:
Set the driver type to rndis (see above).
Download this driver on the Windows machine and unzip it somewhere.
Open the devices manager:
Select Properties of the Composite KVM Device:
Select the RNDIS Device and click properties:
Switch to the Driver tab and then click Update driver.
Click Browse my computer for driver software:
Click Let me pick from a list of available drivers on my Computer:
From the list of available hardware types, scroll down and select Network adapters, then click Next:
Click Have disk:
Click Browse, navigate to the folder where you've stored the driver and select the RNDIS.inf, press Open and then OK:
Select Acer Netchip RNDIS/Ethernet Gadget and click Next:
Dismiss the warning about non-compatible drivers by clicking Yes:
You're done - the device should now be recognized:
Verify the card is working by pinging your PiKVM in a console: