cd ../articles

Networking Security Homelab

A Tailscale bastion and Wake-on-LAN: reaching two labs from anywhere

WireGuard covers the homelab, but my second lab lives on a desktop that sleeps. A small LXC bastion running Tailscale, a static route and a Wake-on-LAN script tie everything together.

  • Tailscale
  • LXC
  • Wake-on-LAN
  • Routing

My homelab now has a sibling: a second lab on my desktop PC, with its own networks in 10.10.0.0/16. The desktop sleeps most of the time, my laptop moves around, and I was tired of juggling SSH sessions from wherever I happened to be. So I gave the lab a single front door for administration: a small bastion container, joined to a Tailscale network, with a route to the second lab and a way to wake it up.

The problem

  • Two labs on two machines. The Proxmox host (192.168.2.100) and the desktop (192.168.2.9), which hosts several lab subnets behind it.
  • Machines that are not always on. The desktop sleeps; there is no point leaving it running for an occasional lab session.
  • Tools in one place. Terraform, Ansible and SSH keys for both labs should live on one admin machine, not be copied to every laptop.
  • No new port forward. WireGuard already covers the family services. I did not want to expose anything else.
tailscale-bastion.svg
One front door for two labs
One front door for two labs

Why Tailscale next to WireGuard

My WireGuard serverTailscale
TopologyHub and spoke: everything through homeMesh: devices talk directly
Port forwardingUDP 51820 on the ISP boxNone (NAT traversal, relay fallback)
Key managementMy script, by handAutomatic, tied to an identity login
Access rulesFirewall on the serverCentral ACLs per device / user
Depends on a third partyNoCoordination server (data stays peer to peer)
I use it forPhone and family access to servicesMy own admin devices

Tailscale is WireGuard underneath. What it adds is the coordination: every device I own (laptop, desktop, the second lab, the bastion) can reach the others wherever they are, without me opening ports or exchanging keys. The trade-off is trusting a coordination service for key distribution, which I accept for admin devices but not for the family VPN.

The bastion container

CT 113, epsilon: unprivileged Debian 13, 2 cores, 2 GB of RAM for Terraform and Ansible runs, on vmbr1 with the Proxmox firewall enabled on its interface. It holds an admin user with sudo, my SSH keys for both labs, Terraform, Ansible and a node_exporter for monitoring.

Giving a container a TUN device

Like WireGuard, Tailscale needs /dev/net/tun, which unprivileged containers do not get. Two steps on the host:

proxmox host
# load the tun module now and at every boot
modprobe tun
echo tun > /etc/modules-load.d/tun.conf

# pass the device through to CT 113
pct set 113 --dev0 /dev/net/tun
pct reboot 113

The dev0 option is the modern Proxmox way; it replaces the two raw lxc.cgroup2 / lxc.mount.entry lines I used for the WireGuard container.

Installing and joining

inside CT 113
curl -fsSL https://tailscale.com/install.sh | sh
systemctl enable --now tailscaled
tailscale up --accept-routes      # prints a login URL, open it on another device
tailscale status

--accept-routes lets the bastion use subnet routes advertised by other machines on my tailnet, so it can reach networks behind them, not just the machines themselves.

tailscaled would not start

systemctl status tailscaled just said it failed. The journal (journalctl -xeu tailscaled) was vague too. What finally showed the real error was running the daemon by hand: tailscaled --cleanup; tailscaled. It could not open /dev/net/tun: the module was not loaded on the host yet. ls -l /dev/net/tun inside the container is the 2-second check I now do first.

Routing to the second lab

The second lab's subnets sit behind the desktop. For every container on the homelab (not just the bastion) to reach them, the Proxmox host needs a route:

/etc/network/interfaces · vmbr1
post-up ip route add 10.10.0.0/16 via 192.168.2.9
ip route get 10.10.0.1        # must say: via 192.168.2.9 dev vmbr0
ping -c2 10.10.10.1           # gateways of the second lab's subnets
ping -c2 10.10.20.1

Replies find their way back without any change on the desktop: traffic from vmbr1 leaving through vmbr0 is already masqueraded by the host, so the second lab sees it coming from 192.168.2.100, an address on its own LAN.

Waking the desktop

None of this helps if the desktop is asleep. Wake-on-LAN sends a "magic packet" (the MAC address repeated 16 times) that the network card listens for even when the PC is off. My script on the host sends it, then waits until the machine answers:

/opt/scripts/wol.sh
#!/bin/bash
# Wake the desktop with a directed broadcast on the LAN
MAC="xx:xx:xx:xx:xx:xx"
BROADCAST="192.168.2.255"
DESKTOP="192.168.2.9"

echo "Sending magic packet to $MAC via $BROADCAST"
wakeonlan -i "$BROADCAST" "$MAC"

echo "Waiting for it to wake up (30 s max)..."
for i in {1..30}; do
    if ping -c 1 -W 1 "$DESKTOP" > /dev/null 2>&1; then
        echo "Desktop online after ${i}s"
        exit 0
    fi
    sleep 1
done
echo "Timeout: check the sleep state and the WoL settings"
exit 1

Use the broadcast address, not the IP

A sleeping PC has no ARP entry, so a packet sent to its IP never leaves the host. Sending to the subnet's broadcast address (-i 192.168.2.255) reaches every card on the LAN, including the sleeping one. The default (255.255.255.255) can go out the wrong bridge on a host with several.

WoL is a BIOS and an OS setting

It has to be enabled in the firmware and on the network adapter in the OS ("allow this device to wake the computer", "magic packet only"). Windows fast startup can also prevent it from a full shutdown.

A session today

  1. From anywhere, on the laptopTailscale is up, so ssh admin@epsilon works the same at home or at school.
  2. Wake the second labOne command on the Proxmox host runs wol.sh; about twenty seconds later the desktop answers.
  3. Work from the bastionTerraform and Ansible run from the bastion against either lab, with the keys never leaving it.

Security notes

The bastion is the only machine holding keys to both labs, so it deserves the strictest treatment. Where it stands today:

  • Small surface. Only SSH and node_exporter listen (plus a local-only mail relay). Root may log in with a key only.
  • Off when unused. It is not started at boot. When I am not doing lab work, that door does not exist.
  • To fix: password logins. sshd -T still shows passwordauthentication yes for normal users. Switching it off is the next change.
  • To add: Tailscale ACLs so only my own devices can reach the bastion's SSH port, and keep device key expiry on for anything that leaves the house.

What is next

Advertising the homelab subnet from the bastion (--advertise-routes=192.168.1.0/24) would let my laptop reach every container directly over Tailscale, and moving the WoL trigger onto the bastion would make the whole flow one command. Both are small; the ACLs need to be right first.