initial commit: wirecon WireGuard stack

Rootless-Docker server (wireguard-go + Caddy sharing netns) and
unprivileged-LXC client (kernel WG + systemd watchdog/monitor/MTU-probe)
with curl-pipeable bootstrap. Tuned for Telekom DSL/LTE Hybrid uplinks.
This commit is contained in:
d4nn13 committed 2026-04-19 18:20:21 +02:00
commit 49b01dfcd3
19 files changed
+770

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
FROM alpine:3.20
RUN apk add --no-cache \
wireguard-tools \
wireguard-go \
iptables \
ip6tables \
iproute2 \
bash \
curl \
tini
ENV WG_QUICK_USERSPACE_IMPLEMENTATION=wireguard-go \
WG_SUDO=0
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY healthcheck.sh /usr/local/bin/healthcheck.sh
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/healthcheck.sh
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]
+32
View File
@@ -0,0 +1,32 @@
# /etc/wireguard/wg0.conf on the Docker (server) side.
# Rename to wg0.conf and fill in the marked fields.
#
# Generate keys:
# wg genkey | tee server.key | wg pubkey > server.pub
# wg genkey | tee client.key | wg pubkey > client.pub
[Interface]
# Server's tunnel address. Pick a subnet that doesn't clash with 192.168.1.0/24.
Address = 10.42.0.1/24
ListenPort = 51820
PrivateKey = REPLACE_WITH_SERVER_PRIVATE_KEY
# Match MTU on both ends. 1280 is safe default behind Telekom Hybrid.
MTU = 1280
# Enable forwarding + MASQ inside the container's own netns so traffic from
# the proxy container (sharing this netns) can flow into wg0 and back.
# No host iptables are touched.
PostUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -A FORWARD -i %i -j ACCEPT
PostUp = iptables -A FORWARD -o %i -j ACCEPT
PostDown = iptables -D FORWARD -i %i -j ACCEPT
PostDown = iptables -D FORWARD -o %i -j ACCEPT
[Peer]
# The LXC client.
PublicKey = REPLACE_WITH_CLIENT_PUBLIC_KEY
# Route both the client's tunnel IP and its LAN subnet back through wg0.
AllowedIPs = 10.42.0.2/32, 192.168.1.0/24
# Server should not set PersistentKeepalive — the client drives this, since
# it's the one behind NAT / hybrid uplink.
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail
IFACE="${WG_INTERFACE:-wg0}"
CONF="/etc/wireguard/${IFACE}.conf"
log() { printf '%s wirecon-wg[%s] %s\n' "$(date -u +%FT%TZ)" "$$" "$*"; }
if [[ ! -r "$CONF" ]]; then
log "FATAL: $CONF missing or unreadable"
exit 1
fi
if [[ ! -e /dev/net/tun ]]; then
log "FATAL: /dev/net/tun not present; mount it from the host"
exit 1
fi
shutdown() {
log "shutting down ${IFACE}"
wg-quick down "$IFACE" || true
exit 0
}
trap shutdown SIGINT SIGTERM
log "bringing up ${IFACE} (userspace impl: ${WG_QUICK_USERSPACE_IMPLEMENTATION})"
wg-quick up "$IFACE"
log "interface up; endpoint info:"
wg show "$IFACE" | while IFS= read -r line; do log " $line"; done
# Park foreground on a loop so signals reach us.
while :; do
sleep 60 &
wait $!
done
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Healthcheck: the interface must exist and have at least one peer.
# A stale handshake is not failed here — that's the watchdog's job on the
# LXC (client) side; the server is passive and only responds.
set -euo pipefail
IFACE="${WG_INTERFACE:-wg0}"
ip link show "$IFACE" >/dev/null 2>&1 || exit 1
wg show "$IFACE" >/dev/null 2>&1 || exit 1
# Must have at least one peer configured.
peers=$(wg show "$IFACE" peers | wc -l)
[[ "$peers" -ge 1 ]] || exit 1
exit 0