Repository navigation
Description
Environment
K8s (k3s v1.35.9+k3s1, Flux v2.10.0), wiredoor-gateway chart 1.1.1
Describe the bug
The gateway container can't come back after a container restart inside the same pod.
In Kubernetes a container restart (liveness probe, OOM, crash) keeps the pod network namespace. wg0 and the iptables rules from PostUp live in that netns, so they survive. /etc/wireguard and /var/run/wiredoor are in the container fs, so they are gone.
connect-wiredoor then runs wiredoor connect, which writes wg0.conf and calls wg-quick up wg0. wg-quick refuses because the interface exists (wg-quick: `wg0' already exists). wiredoor drops wg-quick's stderr and prints the generic NET_ADMIN hint instead.
What happens next depends on the image:
- v1.2.0 / v1.2.2: the script keeps going and
tcpdump -i wg0attaches to the old interface. Nothing re-runswg-quick up. If the old interface no longer works, the liveness probe keeps restarting the container and it never recovers. - v1.2.3 / main: I haven't run it, but
connect-wiredoornow hasset -eu, so as far as I can tell the failed connect exits the container and it fails the same way on every restart. That would be a CrashLoopBackOff until the pod is deleted.
Only deleting the pod (new netns) fixes it. I think wiredoor/wiredoor#142 is the same thing: its log shows the NET_ADMIN error followed by listening on wg0, which only happens when wg0 already existed.
Possible fix in manualLinuxConnect(): after writing wg0.conf, if wg0 already exists run wg-quick down wg0 before wg-quick up wg0. That removes the interface and runs PostDown, so no rules are left behind. It would also help to log wg-quick's stderr when up fails.
Kubernetes users can't change the command through the chart, so right now the only way around it is a post-renderer. Mine:
sudo /sbin/ip link delete wg0 2>/dev/null || true
dnsmasq --server=127.0.0.11 --listen-address=0.0.0.0 --bind-interfaces
sudo wiredoor connect --url "$WIREDOOR_URL" --token "$TOKEN"
exec sudo wiredoor status --watch --interval 15This survives restarts, but ip link delete skips PostDown, so every restart adds the PostUp rules again. After 6 restarts of one pod I have 3 copies of each FORWARD and MASQUERADE rule. wg-quick down in the CLI would avoid that, but in the entrypoint the config file is already gone at that point.
Steps to reproduce
- Deploy the wiredoor-gateway chart and wait until the gateway is connected.
- Make the container restart without deleting the pod. For me it was the liveness probe restarting it.
- Check
kubectl logs <pod>and the restart count.
Logs or error output
ERROR: Unable to connect to tunnel, please review your user permissions or if you are inside container ensure that you have added the capability NET_ADMINThe real error from wg-quick, which is not shown:
wg-quick: `wg0' already existsWiredoor version
wiredoor-cli image v1.2.0 and v1.2.2. v1.2.3 / main is the same from reading the code.
Activity
d-o-it commentedon Oct 30, 2026
Correction, I got the mechanism wrong.
cmd/connect_unix.goonly callsConnect()when wg0 doesn't exist, otherwise it just prints the status and exits 0 (same in v1.2.0 and v1.2.2). Sowg-quick upnever runs against an existing wg0, and the v1.2.3set -eucrash loop I described doesn't follow from it.Checked today on v1.2.2: the container got restarted by the liveness probe while the server was briefly unreachable,
wiredoor connectprinted "Tunnel seems active, but Wiredoor server unreachable." and the old wg0 kept working once the server was back. No duplicate iptables rules either; those came from my ownip link delete wg0workaround.I can't explain the crash loop I had in June with this, so closing. Sorry for the noise, I'll open a new one if I can reproduce it.