scope down to LXC client side only; drop docker/ server tree

The server side is out of scope — this repo now ships only the Alpine
LXC tooling (installer, OpenRC watchdog/monitor, MTU probe) and the
Proxmox-host creator. Rewrite the README around that focus.
This commit is contained in:
d4nn13 committed 2026-04-19 18:47:06 +02:00
1 parent 810bad6ea5
commit 2d07a590e2
8 files changed
+65 -235

No files matched your search

+65 -35
View File
@@ -1,69 +1,99 @@
# wirecon
WireGuard tunnel between a **rootless-Docker** internet host and an **unprivileged Alpine LXC** on Proxmox, with Caddy reverse-proxying inbound traffic into the LXC's LAN. Tuned for flaky uplinks (Telekom DSL/LTE Hybrid) with a fast-reconnect watchdog and structured logging.
WireGuard **client** tooling for an unprivileged Alpine LXC on Proxmox. Connects the LXC to an existing WireGuard server over a flaky uplink (built for Telekom DSL/LTE Hybrid, where MTU pitfalls cause silent stalls) with:
```
internet Telekom Hybrid (DSL+LTE)
clients ──► Docker host ══════ wg0 (UDP 51820) ══════ LXC ──► 192.168.1.0/24
(Caddy + (Alpine + kernel WG
wireguard-go, + OpenRC watchdog
rootless) & monitor)
```
- a Proxmox-host one-liner that creates the LXC from scratch
- an OpenRC **watchdog** that detects stale handshakes / ping loss and re-dials fast
- a continuous **monitor** that emits structured logs for post-mortem analysis
- an **MTU probe** that finds the real path MTU via DF-ping binary search
The server side is intentionally out of scope — point the LXC at any existing WireGuard endpoint.
## Install
### Proxmox side — one-liner (creates the LXC from scratch)
Run on the **Proxmox host** as root:
```
curl -fsSL https://git.d4nn13.de/d4nn13/wirecon/raw/branch/main/proxmox/create-lxc.sh | bash
```
Defaults: Alpine template (latest), hostname `concad`, 1 core, 256 MiB RAM, 2 GiB disk, DHCP on `vmbr0`, auto-picked VMID. The script creates the container, applies the `/dev/net/tun` passthrough, starts it, and chains into the in-LXC bootstrap which clones the repo and runs `lxc/install.sh`. Override defaults via env vars:
That script:
1. picks the next free VMID (`pvesh get /cluster/nextid`)
2. downloads the latest Alpine template if missing
3. creates an unprivileged LXC (`concad`, 1 core, 256 MiB RAM, 2 GiB disk, DHCP on `vmbr0`, nesting+keyctl features)
4. appends the `/dev/net/tun` passthrough to `/etc/pve/lxc/<VMID>.conf`
5. starts the container, waits for DHCP
6. chains into `lxc/bootstrap.sh` inside the LXC, which clones this repo to `/opt/wirecon` and runs `lxc/install.sh`
Override defaults via env vars:
```
HOSTNAME=tunbox MEMORY=512 STORAGE=fast-nvme \
bash -c "$(curl -fsSL https://git.d4nn13.de/d4nn13/wirecon/raw/branch/main/proxmox/create-lxc.sh)"
```
### Finishing up
Available overrides: `HOSTNAME`, `CORES`, `MEMORY`, `DISK`, `BRIDGE`, `STORAGE`, `TEMPLATE_STORAGE`, `WIRECON_REPO`, `WIRECON_REF`.
Edit `/etc/wireguard/wg0.conf` (keys, endpoint, LAN iface in `PostUp`), optionally tune `/etc/wirecon/wirecon.conf`, then:
## Finishing up (inside the LXC)
```
pct enter <VMID>
vi /etc/wireguard/wg0.conf # PrivateKey, Peer PublicKey, Endpoint, MTU, LAN iface in PostUp
vi /etc/wirecon/wirecon.conf # PEER_IP + watchdog thresholds (optional)
rc-update add wg-quick.wg0 default && rc-service wg-quick.wg0 start
rc-update add wirecon-watchdog default && rc-service wirecon-watchdog start
rc-update add wirecon-monitor default && rc-service wirecon-monitor start
tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
```
### Docker side (internet host)
Rootless Docker daemon already running:
```
git clone https://git.d4nn13.de/d4nn13/wirecon.git
cd wirecon/docker
cp wg/config/wg0.conf.example wg/config/wg0.conf # fill in keys
# edit proxy/Caddyfile for your sites
docker compose up -d --build
```
Host prereqs:
- `/dev/net/tun` readable by the rootless user
- `sysctl net.ipv4.ip_unprivileged_port_start=80` if you want 80/443 bound directly
## Layout
```
docker/ rootless-Docker stack: wg (wireguard-go) + Caddy sharing netns
lxc/ Alpine installer, OpenRC services, watchdog/monitor/MTU-probe
proxmox/ host-side LXC creator + tun-passthrough snippet
lxc/
install.sh idempotent apk + OpenRC installer (runs inside the LXC)
bootstrap.sh clones repo into /opt/wirecon then calls install.sh
etc/init.d/ OpenRC services: wirecon-watchdog, wirecon-monitor
etc/wirecon/wirecon.conf tunable thresholds (peer IP, handshake age, MTU bounds…)
etc/wireguard/wg0.conf.example
usr/local/bin/
wirecon-watchdog.sh one tick: handshake age + in-tunnel ping → reconnect if needed
wirecon-watchdog-loop.sh supervise-daemon target that re-runs the tick every WATCHDOG_INTERVAL
wirecon-monitor.sh long-running structured-log emitter
wirecon-mtu-probe.sh DF-ping binary search → recommended WG MTU
proxmox/
create-lxc.sh host-side LXC provisioner (the one-liner above)
lxc.conf.snippet tun passthrough lines (also appended by create-lxc.sh)
```
## How the watchdog decides to reconnect
Every `WATCHDOG_INTERVAL` seconds (default 20 s), one tick runs:
1. **Interface check** — `ip link show wg0`; if missing → reconnect immediately.
2. **Handshake age** — `wg show wg0 latest-handshakes`; if older than `HANDSHAKE_MAX_AGE` (default 180 s), mark failure.
3. **In-tunnel ping** — `ping -I wg0 -c 3 -W 2 $PEER_IP`; if loss ≥ `PING_LOSS_THRESHOLD`, mark failure.
4. **Failure streak** — only after `FAIL_STREAK_THRESHOLD` consecutive failed ticks (default 2 = 40 s) does it actually `wg-quick down && up`. This prevents a single LTE hiccup from thrashing the tunnel.
Every decision — pass, fail, streak bump, reconnect — is logged as a single `key=value` line with a reason.
## Tuning
- **MTU** — default `1280`. Run `/usr/local/bin/wirecon-mtu-probe.sh` inside the LXC to find the real path MTU; update `MTU =` on both peers.
- **Watchdog** (`/etc/wirecon/wirecon.conf`): `HANDSHAKE_MAX_AGE`, `PING_LOSS_THRESHOLD`, `FAIL_STREAK_THRESHOLD`, `WATCHDOG_INTERVAL`.
- **Logs** — structured `key=value` lines in `/var/log/wirecon-*.log`; grep-friendly.
| File | What to tune |
|---|---|
| `/etc/wireguard/wg0.conf` | `MTU` (run `wirecon-mtu-probe.sh` first), LAN iface in the `PostUp` iptables MASQ rules |
| `/etc/wirecon/wirecon.conf` | `PEER_IP`, `HANDSHAKE_MAX_AGE`, `PING_LOSS_THRESHOLD`, `FAIL_STREAK_THRESHOLD`, `WATCHDOG_INTERVAL`, `MONITOR_INTERVAL` |
## Logs
Both services write `key=value` structured lines; grep and `awk` friendly:
```
tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
grep event=reconnect /var/log/wirecon-watchdog.log
awk -F'rtt_ms=' '/rtt_ms=/{split($2,a," "); print $0}' /var/log/wirecon-monitor.log
```