Skip to content
husnjak.me

All projects

Homelab case study

A three-node Proxmox cluster built so that lab failures never take the household offline, with segmented networking, tested failover, encrypted backups and an isolated network for an AI coding agent.

Stack: Proxmox VE, Proxmox Backup Server, MikroTik RouterOS, OPNsense, Headscale, WireGuard, Caddy, Squid, ZFS

Context and goals

I built it to practise at home what I do at work (Proxmox, firewalls, VPN, high availability) in a place where I can break things without taking the household offline. The one rule that shaped everything else is that a mistake in the lab must never break the household’s internet or Wi-Fi.

The lab is a three-node Proxmox VE cluster behind a MikroTik edge router and a managed core switch. It has segmented networks with default-deny between zones, tested high availability, encrypted backups, two independent ways in from outside, publicly trusted certificates on the management interfaces, and an isolated network for an AI coding agent.

Hardware: one Lenovo ThinkCentre M70q (Intel Core i5-10400T) and two M720q (Core i5-9400T) with 16 GB of RAM each, a MikroTik hAP ac³ as the edge router and a MikroTik CRS310 as the core switch.

Architecture

The edge router is the only device with a public address. Two cables join it to the lab switch: one carries the ordinary household network, the other a tagged trunk for the lab. Everything internet-facing sits behind a second firewall.

Four paths show how the pieces fit together:

  • Home device to a lab service: device, edge router (which routes between VLANs), trunk, switch, node, guest.
  • Phone away from home: a WireGuard tunnel terminates on the edge router, then traffic is routed like any home device.
  • Internet to the VPN coordinator: public address, port forward on the edge router, a transit link, the DMZ firewall, then the DMZ. Replies take the same route back.
  • Cluster heartbeat and backups: these stay inside the switch and never pass through a router.
Homelab topologyThe internet reaches the household router, which also hosts the WireGuard VPN. Two cables join the router to the lab switch: the household network and a lab trunk. The switch connects the three-node Proxmox cluster. Inside the cluster, a management and lab zone sits above the firewall VM. A separate transit link joins the router directly to the firewall. The firewall guards two zones: an agent zone with the coding agent, and a DMZ with the VPN coordinator and the egress proxy. The agent reaches the internet only through the egress proxy.InternetHousehold routerWireGuard VPN, port forwardhouseholdlab trunkLab switchtransitProxmox clusterNode 1Node 2Node 3Management and labbackups, media, smart homeFirewall VMdefault denyAgent zonecoding agent,no DNSDMZVPN coordinator,egress proxy
Simplified topology. The agent zone reaches the internet only through the egress proxy in the DMZ, via the firewall.

Network and segmentation

Five VLANs each have one job and one gateway:

Network Purpose
Management Hypervisors, backup server, subnet router
Lab Workloads such as media and home automation
Cluster Corosync heartbeat only, no gateway at all
DMZ Internet-facing services, behind the firewall
Transit Routed link between the edge router and firewall

A sixth network, for the coding agent, was added later (see Security).

Every boundary is default-deny, and traffic only flows where a rule says so. A few choices carry most of the weight:

  • Management and lab share an interface list on the router, but no rule allows traffic between them. The final deny rule therefore stops a lab VM from reaching the hypervisors.
  • The DMZ can reach the internet and nothing private. The DMZ firewall allows its hosts out only to non-private destinations, and its trunk deliberately excludes the management VLAN, so a compromised firewall cannot touch the hypervisor network.
  • The cluster network has no gateway. Heartbeat traffic is never routed, and a second heartbeat link on the management network is the fallback.
  • One translation, not two. The firewall does not NAT its own downstream; the edge router already routes the DMZ back and translates once to the public address.

Virtualisation

Three Proxmox VE nodes with identical versions and a quorum of two. Each has ZFS on its root disk, because replication and snapshots need it. Guests choose their network with a VLAN tag on the virtual NIC.

High availability is built on ZFS replication, not shared storage:

  • Each protected guest replicates to a partner node every 15 minutes, sending only changed blocks.
  • A node that stops answering is fenced by its watchdog, which guarantees the guest is never running twice. The HA manager then starts it on the node that holds the replica.
  • Affinity rules limit each guest to the nodes that have its disks. No rule is strict, so guests stay put and move only when their node fails. The one exception is the Home Assistant VM, which is restricted to a single node (see Workloads).

I tested it on a throwaway VM rather than assume it works:

Test Result
Live migration between nodes 19 seconds, one lost ping
HA failover with a node’s network cable pulled Back up in about 3 min 15 s
Backup, then restore as a new VM Passed, booted and got its own DHCP lease

The failover took longer than the usual two minutes because the cut-off node was also the HA master, so a new master had to be elected before recovery could start. Worst-case data loss is the replication interval, 15 minutes.

Two practical rules came out of testing: never use a graceful shutdown to test failover (it is handled as a clean stop, not a failure), and keep ISO images off replicated guests, because an ISO on node-local storage blocks migration.

Workloads

Besides the infrastructure guests, the cluster runs a few services for the household:

  • Jellyfin, a media server for the household.
  • Home Assistant, in a VM: a smart plug, a camera, temperature and humidity sensors and a presence sensor, shown on dashboards and used in automations.
  • Zigbee. A USB Zigbee coordinator is passed through to the Home Assistant VM, which pins the VM to the one node that has the dongle. Its HA rule is therefore restricted to that node. A NIC hang once fenced that node, the VM failed over to a node without the dongle, and every Zigbee device went offline. The fix was the pinning and a NIC offload workaround (see Lessons).
Zigbee meshA Zigbee coordinator, a USB dongle passed through to the Home Assistant VM, sits at the centre. Four end devices connect to it: temperature and humidity sensors in the living room, the bedroom and the office, and a presence sensor.Zigbee coordinatorUSB dongle on theHome Assistant VMLiving roomtemperature,humidityBedroomtemperature,humidityOfficetemperature,humidityPresencesensor
The Zigbee mesh: the coordinator at the centre, with three temperature and humidity sensors and one presence sensor as end devices.

Automation

Nothing in the lab is infrastructure as code: there is no Ansible or Terraform, and it is configured by hand and documented. What is automated:

  • Certificates: renewal through the DNS-01 challenge (see Security).
  • Backups: a scheduled weekly backup job, with pruning and garbage collection run by the backup server.
  • Health checks: a health-check script for the lab.

Security

Isolation of the household network

The lab hangs off a separate trunk cable. The household network keeps being served by the edge router regardless of what happens to the lab, so a bad firewall rule or a dead node cannot take home internet or Wi-Fi down.

Valid certificates without exposing anything: DNS-01

The Proxmox interfaces use real Let’s Encrypt certificates for names under huslab.dev. The usual HTTP-01 challenge would need port 80 open to the internet on every node, Instead Proxmox uses the DNS-01 challenge:

  1. Proxmox asks Let’s Encrypt for a certificate for the node’s name.
  2. Proxmox writes a temporary TXT record into the DNS zone through the Cloudflare API.
  3. After a short delay, Let’s Encrypt reads the record from public DNS and validates the name.
  4. Proxmox removes the record, downloads the certificate and reloads its web proxy.

Details that matter:

  • Nothing is exposed and no internal addresses are in public DNS. The lab names resolve only on the home network, from static entries on the router, and over the VPN, where Headscale hands out the same names to every device through MagicDNS.
  • The API token is scoped to one zone with edit rights on DNS records and read rights on the zone. Nothing else.
  • Renewal is automatic. The result is a valid padlock on all three nodes with no certificate warnings and no hosts-file edits on any client.
  • A .dev domain is HTTPS-only in browsers (HSTS preload), which is a useful forcing function: every lab name must have a real certificate.

Two independent ways in

  • WireGuard on the edge router is the break-glass path. It does not depend on the cluster, so it works even when everything behind it is down. It is a split tunnel, so only lab and home traffic goes through it.
  • Headscale (a self-hosted Tailscale control server) is the convenient everyday mesh. It runs in the DMZ behind the firewall and is reached from the internet through a port forward, a transit link and one firewall rule. Caddy terminates TLS with an automatically renewed certificate.

A separate subnet router lets tailnet devices reach the management and lab networks. This is the interesting design decision, covered below.

Backups that a compromised node cannot destroy

Proxmox Backup Server runs on the third node, apart from the nodes that normally host the firewall and the VPN coordinator. Backups are deduplicated and encrypted on the client side before they leave the node, with the key stored offline.

The cluster logs in with an account that may write backups but not delete them, and no SSH keys from the hypervisors exist on the backup server. A compromised node therefore cannot wipe history or log in to the backup host. Retention is handled by the backup server’s own prune job: weekly backups, keep the newest three per guest.

I verified the whole chain by restoring a backup as a new VM and booting it.

An isolated network for an AI coding agent

I run an AI coding agent (Claude Code) in its own VM on a dedicated VLAN behind the firewall. Its only way out is an allow-listing Squid proxy in the DMZ. Everything else, including the rest of the lab, is dropped and logged.

  • Default-deny with three narrow exceptions: the proxy port, time sync from the firewall, and ping to the gateway.
  • No DNS in the VM at all. With an explicit proxy the client sends the hostname and the proxy resolves it, which also closes DNS tunnelling as an exfiltration path.
  • A domain allow-list, kept in one file on the proxy. A short list covers the agent’s own API, GitHub, the Ubuntu and container registries and the language package repositories. Anything else returns 403 and the agent is told to stop and ask, not work around it.
  • The proxy is a separate box in the DMZ, not a firewall plugin and not in the agent’s VLAN. The firewall decides who may talk to whom; the proxy decides which domains. If the proxy breaks, only the agent loses internet. The agent cannot take over the proxy’s address because it is not in the same network.
  • Layers of control, honestly labelled. Instruction files are guidance the model can drift from. Permissions in the tool (no sudo, no reading SSH keys, confirm before pushing) are enforced by the program. The firewall and proxy are enforced by the network and hold even against root inside the VM.

This site was built inside that VM.

Decisions and trade-offs

Decision Why
Separate trunk cable for the lab A lab mistake cannot break the household network.
ZFS replication plus HA, not shared storage Fewer moving parts. Cost: up to 15 minutes of data loss on node failure.
DNS-01 instead of HTTP-01 for node certificates Nothing has to be opened to the internet.
Headscale coordinator kept out of the management network It is internet-facing, so routing from it would require opening the DMZ towards management.
Dedicated subnet router in the management network Headscale only coordinates; a client inside the target network has to forward the packets.
Two remote-access paths WireGuard works with the cluster down; the mesh is nicer day to day.
Separate Squid proxy for the agent Allow-only lists are awkward in the firewall plugin, and a failure stays contained.
Backup account that cannot delete A compromised node cannot erase the backups.
Home Assistant stays on the backup server’s node Known limitation: its Zigbee USB dongle pins it there, so one node holds both the backups and that VM.

Known limits, stated plainly:

  • One copy of the backups, on one disk. A second copy and a scheduled verify job are not done yet.
  • Tailnet access to the lab depends on three guests being up (firewall, Headscale, subnet router). WireGuard is the fallback when any of them is down.

Lessons

Problems I hit and how each was solved:

  • A backup job that “failed” while the backups were fine. Nightly jobs reported errors for days. The backups themselves succeeded; the job’s own prune step lacked permission, because the backup account deliberately cannot delete. Setting the job to keep everything and letting the backup server prune on its own schedule removed the error and matched the security model. Lesson: a deliberately restricted account fails any step that needs the withheld permission, so give each task, here pruning, to the component that is allowed to do it.

  • Hairpin NAT on a home network. A logged-out VPN client on the home Wi-Fi resolved the coordinator’s public address and tried to connect to it from inside the house. The port forward only matched traffic arriving from the internet, so the request hit the router itself and was refused. Logins worked from mobile data and other networks, which is what made it confusing. A hairpin rule that forwards internal traffic aimed at the public address fixed it, with a backup of the router configuration taken first. Lesson: a port forward that matches only traffic from the internet does not cover clients inside the network that use the public address, so internal clients need their own rule.

  • DNS that a client rewrote under me. The subnet router stopped reconnecting after a restart because the Tailscale client had replaced the container’s DNS settings, so the coordinator’s name resolved to the public address, which is unreachable from inside. Everything in the path was healthy; the fix was pinning the name locally. Lesson: when every component in the path is healthy, check which address the client actually resolves, and pin critical names where a client cannot overwrite them.

  • A firewall rule I had not written yet. The first join of the subnet router hung because the router had no rule from management to the DMZ. The symptoms were a hung join and a timed-out health check; the cause was a missing forward rule. Lesson: under default-deny every new flow needs its own explicit rule, and a timeout is what a missing rule looks like.

  • A service in a container that would not start. The backup server’s web proxy failed on boot inside an unprivileged container. Two changes fixed it: enabling nesting, which the container’s systemd expects, and a systemd drop-in that recreates its runtime directory with the right owner. Lesson: an unprivileged container needs the feature flags and file ownership its init system expects, and they have to be set explicitly.

  • A Zigbee dongle that pinned a VM. A NIC hang fenced the node that ran Home Assistant. The HA manager started the VM on a node without the Zigbee dongle, so every Zigbee device went offline. The fix was to pin the VM to the node with the dongle, restricting its HA rule to that node, and to apply a NIC offload workaround for the hang. Lesson: hardware passed through to a VM ties it to one host, so tell the HA manager and restrict the VM’s rule to that node; failover to a host without the device only moves the outage.

What I would do differently

Start it years earlier. And keep the router passwords somewhere more reliable than my memory.

What’s next

The notes list these as open:

  • A second copy of the backups on separate hardware, synced from the backup server, and a scheduled verify job.
  • Adding the agent VM to the weekly backup job.
  • Tightening the agent’s allow-list from the proxy log after a few weeks of real use.
Title
Homelab case study
Drawn by
Ivan Husnjak
Sheet
- of 5
Rev
1f63e29
Date