labctl · Training environments

labctl Linux training environments

Create isolated Linux containers for training with systemd, SSH access, resource limits, automatic expiry and configurable network filtering. labctl supports VPS deployment with NAT and LAN deployment with macvlan, five distributions and mode changes during a session. It runs on an Ubuntu 24.04 server.

  • ContainersIncus · LXC · systemd
  • Filteringnftables · Squid
  • DeploymentVPS · LAN with macvlan
  • LifecycleExpiry and cleanup

Separate Linux environments for participants

Each participant receives an isolated environment for Linux, DevOps, networking or programming exercises. Instructors can configure network access and automatically remove expired environments after the session.

Example commands

sudo labctl create -n 20 -i ubuntu -m filtered -t 8h
sudo labctl export > credentials.txt
sudo labctl remove --expired -f

Functions for training environments

Linux containers with an init system, kernel namespaces, network filtering and central administration.

Full systemd containers

Incus/LXC containers with systemd support systemctl, journalctl and hostnamectl.

3 filtering modes

filtered: outgoing traffic limited to the Squid allowlist. allow: outgoing traffic permitted with a blocklist for Tor, gambling and cryptocurrency services. block: outgoing traffic blocked, with package cache access retained.

Mode changes during a session

labctl set-mode --all filtered changes filtering for all containers without restarting them. Existing SSH sessions remain active.

Automatic TTL

Each container has an expiry time. Use --expired with cron to remove expired containers, or --permanent for environments without an expiry time.

VPS & LAN deployment

VPS mode uses one public IP and NAT port forwarding. LAN mode uses macvlan, giving each container an address from the LAN DHCP server. The mode is selected in the configuration.

Five distributions

Ubuntu 24.04 LTS, Fedora 42, Rocky Linux 10, openSUSE Tumbleweed and a custom Netplan Trainer image. Includes vim/nvim, tmux, gcc, nmap, tcpdump, strace and Python.

Netplan Trainer

The Netplan Trainer image includes five exercises. netplan-test validates configuration and shows differences. netplan-apply uses try --timeout 10 and restores the previous configuration if SSH disconnects.

Package cache

apt-cacher-ng on the host caches downloaded packages for subsequent participants. The cache is also available in filtered mode.

Shared lab materials

/opt/labctl/lab-materials/ is mounted read-only as /lab-materials in every container, providing shared access to exercise files.

Port-scan protection

nftables limits new connections per source IP to 30/s for TCP and 10/s for ICMP. Port scanning with nmap -sS from a container is blocked.

SSH by key or password

Root access requires a key. Participants can use a key or a random 12-character password, displayed by labctl list.

Interactive terminal menu

labctl-menu provides an interactive interface built with the rich library. It exposes the same operations as the CLI.

VPS and LAN deployment

VPS mode supports remote participants through one public IP. LAN mode connects containers directly to the local network. Both use the same CLI and container images.

Single public IP · NAT · proxy

Containers use the internal labbr0 bridge (10.200.0.0/24) and NAT through the host. Incus proxy devices expose SSH on assigned ports (host:10100 → :22) and two development ports. This mode supports filtered, allow and block, including changes during a session.

Macvlan · DHCP · direct

Containers connect through macvlan to a physical interface and receive addresses from the LAN DHCP server. Participants connect directly via SSH, without NAT or port forwarding. macvlan bypasses the host's netfilter, so filtered and block require filtering on the LAN router.

Components and state management

labctl uses standard Linux tools with available documentation. State is stored in JSON files on disk. Administration uses the CLI or interactive terminal menu.

Container runtime
Incus 6.x (LXC) · systemd · kernel namespaces
Networking
labbr0 bridge with NAT · Incus proxy devices · macvlan in LAN mode
Firewall
nftables table inet labctl · container traffic rules · scan rate limiting
HTTP filtering
Squid 5 · dstdomain ACLs · whitelist.txt / blocklist.txt
Package cache
apt-cacher-ng in the host network · shared package cache
IPS (optional)
CrowdSec with an iptables bouncer
CLI / TUI
Python 3.10+ · click · rich · labctl-menu
State
/root/.labctl/state.json · incus config user.labctl.* for redundant state storage

Deployment requirements

Deployment requires a VPS or server and SSH access. The setup script installs the required components.

Host

Ubuntu 24.04 (x86_64 or aarch64). 4+ GB RAM, 30+ GB disk. One public IP for VPS mode, or a LAN interface with DHCP for LAN mode.

Ports

Open TCP ports 10000–30199 in the provider's firewall. Administrative SSH uses port 22 or a configured alternative. Other ports are closed by default.

Dependencies

Python 3.10+, Incus 6.x (apt), Docker CE (for Squid + apt-cacher in host network mode). Installed in one shell command.

Setup scripts

setup_host.sh installs the components. labctl setup builds the four base images.

Deployment for schools and companies

We deploy labctl on your VPS, configure security, adapt branding and train staff. Contact us for a quote and licence terms.

Request a deployment →