Skip to content

Instantly share code, notes, and snippets.

@WIPocket
WIPocket / wg-ns.sh
Created October 11, 2025 08:50
A tiny script to run a VPN client and an app inside a network namespace
#!/bin/sh
set -ex
case "$1" in
"")
export PIDFILE ORIG_UID ORIG_GID
PIDFILE=$(mktemp)
ORIG_UID=$(id -u)
ORIG_GID=$(id -g)
trap 'trap - TERM; kill 0; rm $PIDFILE' TERM EXIT