https://github.com/bluecmd/trivial-debian-netns-wireguard
Because all other examples I can find seems so over engineered
https://github.com/bluecmd/trivial-debian-netns-wireguard
Last synced: 4 months ago
JSON representation
Because all other examples I can find seems so over engineered
- Host: GitHub
- URL: https://github.com/bluecmd/trivial-debian-netns-wireguard
- Owner: bluecmd
- License: unlicense
- Created: 2021-01-28T14:15:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-28T14:18:27.000Z (over 5 years ago)
- Last Synced: 2025-10-19T16:57:36.033Z (8 months ago)
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Usage
Add the following to your `/etc/network/interfaces` file:
```
auto vpn0
iface vpn0 inet manual
pre-up (ip netns add $IFACE 2>/dev/null && ip netns exec $IFACE ip link set lo up) || true
pre-up ip netns exec $IFACE ip link del $IFACE 2>/dev/null || true
pre-up ip link add $IFACE type wireguard && ip link set dev $IFACE netns $IFACE
pre-up ip netns exec $IFACE wg setconf $IFACE /etc/wg/$IFACE.conf || (ip netns exec $IFACE ip link del $IFACE; false)
up ip netns exec $IFACE ip link set $IFACE up
up ip netns exec $IFACE ip addr add 10.71.73.26/32 dev $IFACE
up ip netns exec $IFACE ip -6 addr add fc00:bbbb:bbbb:bb01::8:4919/128 dev $IFACE
up ip netns exec $IFACE ip ro add default dev $IFACE
up ip netns exec $IFACE ip -6 ro add default dev $IFACE
down ip netns exec $IFACE ip link del $IFACE
```
This script configures both IPv4 and IPv6 for a Wireguard tunnel, reading configuration from `/etc/wg/vpn0.conf`.
To enter the namespace as your user, do something like: `sudo ip netns exec vpn0 sudo -iu "$USER"`