Prepare:
sudo apt install wireguard
Usage:
- Update server config
# case 1
./vpn-tool setup > /etc/wireguard/wg0.conf
wg syncconf wg0 <(wg-quick strip wg0)
# case 2
./vpn-tool setup > /etc/wireguard/wg0.conf
wg-quick down wg0 # optional
wg-quick up wg0
- Add user
./vpn-tool adduser --id yourname
2.1 If want to advertise a subnet router,
./vpn-tool adduser --id router \
--postup "iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -s 100.10.10.0/24 -o eth0 -j MASQUERADE" \
--postdown "iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -s 100.10.10.0/24 -o eth0 -j MASQUERADE" \
--advertise-routes "10.10.10.0/24"
2.2 To add a user that accepts the routes,
./vpn-tool adduser --id client --accept-routes
- Delete user
./vpn-tool deluser --id yourname
- Delete user
./vpn-tool getuser --id yourname