WireGuard provides a secure, low-latency VPN between all hosts. Server acts as the hub with a public endpoint; desktop and laptop connect to it.
| Host | WireGuard IP | Role |
|---|---|---|
| Server | 10.100.0.1 | Hub (public endpoint) |
| Desktop | 10.100.0.2 | Client |
| Laptop | 10.100.0.3 | Client |
wg030352/udpwg.yhkze.net:30352wg.yhkze.net must resolve directly to the server’s
public IP — WireGuard uses UDP and cannot go through the Cloudflare
proxy. The record is already configured as DNS-only in Cloudflare DNS.
Forward UDP port 30352 to the server (192.168.100.2) on the router. WireGuard clients connect to this port from the internet.
Generate a keypair on each host:
nix-shell -p wireguard-tools
cd /tmp
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
cat privatekey
cat publickeySave the private key securely and note the public key for the next steps.
Edit values/wireguard-keys.nix with the public keys from
each host:
{
server = "SERVER_PUBLIC_KEY_HERE";
desktop = "DESKTOP_PUBLIC_KEY_HERE";
laptop = "LAPTOP_PUBLIC_KEY_HERE";
}On each host, add the private key to SOPS:
sops hosts/<hostname>/secrets/secrets.yamlAdd under system/wireguard/private-key:
system:
wireguard:
private-key: YOUR_PRIVATE_KEY_HERERebuild NixOS on all hosts:
sudo nixos-rebuild switch --flake "path:.#<hostname>"ip addr show wg0Expected output shows the WireGuard interface with assigned IP.
sudo wg showShows peer public keys, endpoints, allowed IPs, and last handshake time.
From desktop or laptop:
ping 10.100.0.1From server:
ping 10.100.0.2 # desktop
ping 10.100.0.3 # laptopEnter Nix shell with required dependencies.
nix-shell -p wireguard-toolsCreate Wireguard configuration file.
[Interface]
PrivateKey = <your-private-key>
Address = 10.100.0.<your-id>/24
[Peer]
PublicKey = O7sztnEM87WxYjdzbSht+jfIQHd025t21kYEsXUqIlM=
Endpoint = wg.yhkze.net:30352
AllowedIPs = 10.100.0.0/24
PersistentKeepalive = 25Activate Wireguard interface
sudo wg-quick up ./wg0.confIf wg show shows no recent handshake:
wg.yhkze.net resolves to server’s public IP
(not a proxy)Check systemd-networkd logs:
journalctl -u systemd-networkd.service -fVerify SOPS secret is accessible:
sudo cat /run/secrets/system/wireguard/private-keyCheck netdev status:
networkctl status wg0Verify routes exist:
ip route | grep 10.100.0Expected output includes route to 10.100.0.0/24 via
wg0.
To rotate keys:
values/wireguard-keys.nixmodules/features/wireguard.nix