All pages

Over Tailscale or NetBird

A tailnet (Tailscale's, or a NetBird network) lets the wall reach KVMs wherever they are, and lets people reach the wall, with no port open to the internet. qKVM talks to each device directly over it, as on a local network; nothing goes through anyone's cloud but the tailnet's own coordination. qKVM never logs, shows back or exports a key or a token of a tailnet.

Finding KVMs on a tailnet

Find KVMs on my network asks the machines of the tailnet as well as this computer's own network:

  • Tailscale: the machines Tailscale says are online, by its command (tailscale status --json) where it is installed, and where it is not (qKVM in a container beside Tailscale's) by Tailscale's local API, over its socket on this computer (/var/run/tailscale/tailscaled.sock): never over a network, and only a socket that is one and is root's or qKVM's own account's. On Windows the local API (a named pipe) is never asked; the command is.
  • NetBird: the machines its client lists (netbird status --json) where it is installed; where it is not (qKVM in a container beside NetBird's), the connected machines its management API lists, once an admin has given that API's address and a token under Settings > Network > NetBird (see qKVM in Docker beside NetBird).

Only addresses of the shared space both give out (100.64.0.0/10) are asked, 256 machines at the most, and what is found is a suggestion: nothing is added to the wall but what you tick. Where a tailnet is there and could not be asked (its local API said no, the token was not taken), the search says why under its result, and is made without it.

Only the wall reaches the KVMs

A tailnet lets every machine in it reach every other until its access rules say otherwise. Give the KVMs and the wall tags of their own, and let only the wall reach the KVMs:

  • A GL.iNet Comet has a Tailscale client of its own: switch it on in the Comet's own web page and sign it in with an auth key tagged tag:kvm. Any other KVM or server's controller is reached through a machine of the tailnet that routes to its network (a subnet router), or is added by its address on the network where the wall is.
  • The wall is tagged tag:qkvm (the auth key of the Compose file below, or tailscale up --advertise-tags=tag:qkvm).
  • Tailscale's access rules (the admin console, Access controls), in place of the default rule that lets everybody reach everything:
{
  "tagOwners": {
    "tag:kvm":  ["autogroup:admin"],
    "tag:qkvm": ["autogroup:admin"]
  },
  "acls": [
    // The wall reaches the KVMs, on every port their video and control use; nobody else does.
    {"action": "accept", "src": ["tag:qkvm"], "dst": ["tag:kvm:*"]},
    // People reach the wall, and nothing else of it.
    {"action": "accept", "src": ["autogroup:member"], "dst": ["tag:qkvm:8787"]}
  ]
}
  • NetBird does the same with groups and policies in its dashboard: a group for the KVMs and one for the wall, a policy from the wall's group to the KVMs' group, one from your team's group to the wall on TCP port 8787, and the policy "Default" (everybody to everybody) taken away.

On the wall's side, --allow-from answers only the addresses it names (and this computer) and turns everybody else away before there is a sign-in page to guess at: --allow-from 100.64.0.0/10 for the tailnet only (see How it is protected). On a plain install, --bind tailscale listens on the tailnet's address and on this computer, and nowhere else.

Names on the tailnet

Tailscale's MagicDNS names every machine: the wall is qkvm to the tailnet, or in full qkvm.<your tailnet>.ts.net. qKVM answers every name under ts.net as its own without more settings (a name of a public domain has to be in allowed_hosts). A KVM can be added by its MagicDNS name where this computer resolves those names (a plain install with MagicDNS on); in a container, add it by its tailnet address (100.x.y.z). Either way its certificate is remembered the first time, as for any KVM.

A certificate browsers trust: --tls-tailscale

Started with --tls-tailscale, qKVM serves HTTPS, and to whoever opens it at its tailnet name (https://qkvm.<your tailnet>.ts.net:8787/) it shows Tailscale's certificate for that name, which browsers trust: no warning to click through. Every other name and address is shown the wall's own certificate (or --tls-cert's), as before.

  • Switch on HTTPS Certificates in Tailscale's admin console (DNS). The machine's name and the tailnet's are then written into the public logs of certificates (Certificate Transparency), as Tailscale says as you switch it on.
  • qKVM asks Tailscale on this computer for the name and the certificate (its command, or its local API in a container), checks that it is one key and its certificate, for that name, in its time, keeps a copy in the data folder (tls/tailscale.pem, its own account's alone) and serves it. It asks again every six hours (Tailscale renews it some thirty days before it ends), every hour in its last two weeks, and soon after a failure; a new one is served from the next connection on, without a restart.
  • The start says which it serves (https://qkvm.<your tailnet>.ts.net:8787/ with Tailscale's certificate for that name, until ..., or why there is none yet, and that the wall's own is served meanwhile), and so does Settings > Network.
  • Where qKVM does not run as root, Tailscale on Linux hands the certificate only to an account named in tailscaled's environment: TS_PERMIT_CERT_UID=qkvm (the account's name or number; for a service, sudo systemctl edit tailscaled and Environment=TS_PERMIT_CERT_UID=qkvm under [Service]). The Compose file below sets it for the image's account,
    1. On Windows and macOS the account signed in to Tailscale may ask.

Never Funnel. Tailscale's Funnel puts a service of a machine on the internet, for anybody, under the same name and certificate. The wall holds the passwords of KVMs and can press the power buttons of servers: it is for your tailnet, not the internet. qKVM never switches Funnel on, nor anything else of Tailscale's; do not put it behind Funnel yourself.

qKVM in Docker beside Tailscale

docker-compose.tailscale.yml runs Tailscale's container and qKVM's in its network, with the socket of Tailscale's local API mounted into qKVM's read-only:

  1. Make an auth key in Tailscale's admin console (Settings > Keys), tagged tag:qkvm.
  2. Put it in a file called .env beside the Compose file: TS_AUTHKEY=tskey-auth-.... It is needed for the first start only; take it out afterwards (the machine's identity is kept in the volume tailscale-state).
  3. docker compose -f docker-compose.tailscale.yml up -d, and open https://qkvm.<your tailnet>.ts.net:8787/ with the setup code from docker compose -f docker-compose.tailscale.yml logs qkvm.
# qKVM beside Tailscale, in containers:   docker compose -f docker-compose.tailscale.yml up -d
#
# Tailscale's own container joins your tailnet as the machine "qkvm", and qKVM's container shares its network: the wall
# is reached at https://qkvm.<your tailnet>.ts.net:8787/ with Tailscale's certificate for that name (--tls-tailscale,
# once HTTPS certificates are on in the tailnet), reaches the KVMs over the tailnet, and "Find KVMs" lists the tailnet's
# machines, read from Tailscale's local API over its socket, which is mounted into qKVM's container read-only.
# Nothing is published on this machine's own network: only the tailnet reaches the wall. Never use Funnel for it.
#
# The auth key: make one in Tailscale's admin console (Settings > Keys), tagged (tag:qkvm, see the guide's chapter
# "Over Tailscale or NetBird" for the access rules), and put it in a file called .env beside this one:
#     TS_AUTHKEY=tskey-auth-...
# It is not written in here, and is needed for the first start only: the machine's identity is kept in the volume
# tailscale-state, and the key can be taken out of .env then. Without one, `docker compose logs tailscale` shows an
# address to sign the machine in at instead.
#
# First run: choose a password at the address above, with the setup code from `docker compose -f
# docker-compose.tailscale.yml logs qkvm`.
services:
  tailscale:
    # Tailscale v1.104.7, pinned by the digest of its image for every platform (the guide says how to move it on).
    image: tailscale/tailscale:v1.104.7@sha256:72c1e19e0aedca96b8533bbb0b4368564410ff20b17e53b804eb6c1f04a31be4
    container_name: qkvm-tailscale
    hostname: qkvm
    restart: unless-stopped
    environment:
      TS_AUTHKEY: ${TS_AUTHKEY:-}
      TS_HOSTNAME: qkvm
      TS_STATE_DIR: /var/lib/tailscale
      # Where qKVM looks for Tailscale's local API (the place tailscaled keeps it on Linux).
      TS_SOCKET: /var/run/tailscale/tailscaled.sock
      # The tailnet as a network of this container's own (not a proxy): qKVM reaches the KVMs through it.
      TS_USERSPACE: "false"
      # qKVM runs as uid 10001: it may ask for this machine's certificate, and for nothing else that changes anything.
      TS_PERMIT_CERT_UID: "10001"
    volumes:
      - tailscale-state:/var/lib/tailscale
      - tailscale-socket:/var/run/tailscale
    devices:
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - NET_RAW
    # To reach the wall from this machine's own network as well (it is the tailnet only without this):
    # ports:
    #   - "8787:8787"

  qkvm:
    image: qkvm/qkvm
    container_name: qkvm
    restart: unless-stopped
    network_mode: service:tailscale
    depends_on:
      - tailscale
    volumes:
      - qkvm-data:/data
      - qkvm-keys:/keys
      - tailscale-socket:/var/run/tailscale:ro
    command: ["--https", "--setup-code", "--tls-tailscale"]
    #
    # /keys holds the independent server storage key. Back up this volume separately
    # from /data. Losing it prevents recovery; account recovery codes cannot replace it.
    # Run with as little as it needs.
    read_only: true
    tmpfs:
      - /tmp
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    logging:
      driver: json-file
      options:
        max-size: "5m"
        max-file: "3"

volumes:
  qkvm-data:
  qkvm-keys:
  tailscale-state:
  tailscale-socket:

qKVM in Docker beside NetBird

docker-compose.netbird.yml runs NetBird's container and qKVM's in its network. NetBird's own client speaks to its container only, so qKVM asks NetBird's management API for the network's machines instead:

  1. Make a setup key in NetBird's dashboard (Setup Keys) and put it in a file called .env beside the Compose file: NB_SETUP_KEY=..., and NB_MANAGEMENT_URL=... where you run NetBird's management yourself.
  2. docker compose -f docker-compose.netbird.yml up -d, and open the wall at its NetBird address with the setup code from docker compose -f docker-compose.netbird.yml logs qkvm.
  3. In NetBird's dashboard (Team > Service Users), make a service user that may see the peers, and a token for it. In qKVM, Settings > Network > NetBird > Set up: the management API's address (https://api.netbird.io for NetBird's own) and the token. qKVM asks the API once before it saves them, and says how many connected machines it lists.

The token is kept encrypted in qKVM's vault and never shown again; it is sent to the address it was entered for and to no other (another address asks for it again), over HTTPS only, by the same outbound rules as alerts (a management API on your own network takes its switch May be a private address). It is in no export, and resetting the accounts (--reset-password) forgets it. The activity log says when the settings changed (netbird_changed), never the token.

# qKVM beside NetBird, in containers:   docker compose -f docker-compose.netbird.yml up -d
#
# NetBird's own container joins your NetBird network as the machine "qkvm", and qKVM's container shares its network:
# the wall is reached at its NetBird address (https://<its 100.x address>:8787/), and reaches the KVMs over NetBird.
# Nothing is published on this machine's own network: only the NetBird network reaches the wall.
#
# The setup key: make one in NetBird's dashboard (Setup Keys), and put it in a file called .env beside this one:
#     NB_SETUP_KEY=...
# Where you run NetBird's management yourself, its address as well:
#     NB_MANAGEMENT_URL=https://netbird.example.org
# Neither is written in here. The key is needed for the first start only: the machine's identity is kept in the
# volumes netbird-config and netbird-state, and the key can be taken out of .env then.
#
# "Find KVMs" lists the NetBird network's machines once qKVM is given NetBird's management API and a token of a service
# user, under Settings > Network: the token is kept encrypted in qKVM's vault and never shown again (see the guide's
# chapter "Over Tailscale or NetBird").
#
# First run: choose a password at the address above, with the setup code from `docker compose -f
# docker-compose.netbird.yml logs qkvm`.
services:
  netbird:
    # NetBird 0.83.1, pinned by the digest of its image for every platform (the guide says how to move it on).
    image: netbirdio/netbird:0.83.1@sha256:3c9d68ae8b730aaed841ff5374e3efad8be550099871a52b1a653d30e5f4faf2
    container_name: qkvm-netbird
    hostname: qkvm
    restart: unless-stopped
    environment:
      NB_SETUP_KEY: ${NB_SETUP_KEY:-}
      NB_MANAGEMENT_URL: ${NB_MANAGEMENT_URL:-https://api.netbird.io}
    volumes:
      - netbird-config:/etc/netbird
      - netbird-state:/var/lib/netbird
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
      - SYS_RESOURCE
    # To reach the wall from this machine's own network as well (it is the NetBird network only without this):
    # ports:
    #   - "8787:8787"

  qkvm:
    image: qkvm/qkvm
    container_name: qkvm
    restart: unless-stopped
    network_mode: service:netbird
    depends_on:
      - netbird
    volumes:
      - qkvm-data:/data
      - qkvm-keys:/keys
    command: ["--https", "--setup-code"]
    #
    # /keys holds the independent server storage key. Back up this volume separately
    # from /data. Losing it prevents recovery; account recovery codes cannot replace it.
    # Run with as little as it needs.
    read_only: true
    tmpfs:
      - /tmp
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    logging:
      driver: json-file
      options:
        max-size: "5m"
        max-file: "3"

volumes:
  qkvm-data:
  qkvm-keys:
  netbird-config:
  netbird-state:

The images beside qKVM's are pinned. Tailscale's and NetBird's containers hold this machine's identity in the tailnet and hand qKVM the key of its certificate, so each file names the image it was written with by its digest (the version is its tag, and the comment above it), never by whatever stable or latest points to the day it is pulled. To move one on, look up the digest of the newer version, for every platform at once, and put the version and the digest in its place:

docker buildx imagetools inspect tailscale/tailscale:<version>    # its first "Digest:" line
docker buildx imagetools inspect netbirdio/netbird:<version>

then docker compose -f <the file> up -d. Release notes are on Tailscale's and NetBird's own pages. qKVM's own image is taken as docker-compose.yml takes it, and updated with docker compose -f <the file> pull qkvm as described in Run it.