Skip to content

Instantly share code, notes, and snippets.

@Belphemur
Created August 4, 2019 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Belphemur/fe695a796337e33376e43f3e095bdff6 to your computer and use it in GitHub Desktop.
Save Belphemur/fe695a796337e33376e43f3e095bdff6 to your computer and use it in GitHub Desktop.
Wirguard with Network Namespace
#!/bin/sh
CONFIG=/etc/wireguard/wg1.conf
DEVICE=wg1
IP="10.11.1.115/16"
ip netns add vpn
ip link add $DEVICE type wireguard
wg setconf $DEVICE $CONFIG
ip link set $DEVICE netns vpn
ip netns exec vpn ip addr add $IP dev $DEVICE
ip netns exec vpn ip link set $DEVICE up
ip netns exec vpn ip route add default dev $DEVICE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment