aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/16_dl/templates/wg_random_tunnel.j2
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2026-07-12 17:34:14 +0300
committerJan Tuomi <jan@jantuomi.fi>2026-07-12 17:34:14 +0300
commit659238b46057ed8a57e28004bb9dc07d6415a959 (patch)
tree973353c6af95c0641714ef806b578fed15385e5f /roles/jails/16_dl/templates/wg_random_tunnel.j2
parentc101bc05df0960f97ba621fc3c86e8b3f3f07615 (diff)
Set up dl jail
Diffstat (limited to 'roles/jails/16_dl/templates/wg_random_tunnel.j2')
-rw-r--r--roles/jails/16_dl/templates/wg_random_tunnel.j217
1 files changed, 17 insertions, 0 deletions
diff --git a/roles/jails/16_dl/templates/wg_random_tunnel.j2 b/roles/jails/16_dl/templates/wg_random_tunnel.j2
new file mode 100644
index 0000000..3cc9492
--- /dev/null
+++ b/roles/jails/16_dl/templates/wg_random_tunnel.j2
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -eux
+
+CONF=$(ls /usr/local/etc/wireguard/ | sort -R | head -n1)
+GATEWAY={{ ingress_ip }}
+
+# Shut down current tunnel
+wg-quick down $(wg show interfaces) || true
+
+wg-quick up "/usr/local/etc/wireguard/${CONF}"
+
+TUNNEL_IF=$(wg show interfaces)
+TUNNEL_IP=$(wg show $TUNNEL_IF endpoints | awk '{print $2}' | tr ':' ' ' | awk '{print $1}')
+
+route delete $TUNNEL_IP
+route add $TUNNEL_IP $GATEWAY