This script will install wireguard, generate configs for a specified number of clients, and enable IP forwarding for all connected clients. This script is idempotent, meaning you can run it multiple times without destroying your existing config. If you need to add another VPN client, just tell the script you need 4 clients instead of 3, etc.
curl https://raw.githubusercontent.com/samurailink3/TomsEasyWireguardSetupScript/main/install-wireguard.bash > install-wireguard.bash
chmod +x install-wireguard.bash
./install-wireguard.bash
If you'd like to use this script in further automation/without user prompting, you'll need to set the following environment variables:
ENDPOINT_IP
NUMBER_OF_CLIENTS
WIREGUARD_INTERFACE
variable to set up new/existing Wireguard tunnels.
export WIREGUARD_INTERFACE=wg1 && /bin/bash install-wireguard.bash
wg0
WIREGUARD_INTERNAL_IP_PARTIAL
variable to control the IP range of the
network created
export WIREGUARD_INTERNAL_IP_PARTIAL=10.72.72 && /bin/bash install-wireguard.bash
10.11.12
.0
/24
.1
WIREGUARD_LISTEN_PORT
variable to control what port wireguard will
listen for incoming connections on.
export WIREGUARD_LISTEN_PORT=12345 && /bin/bash install-wireguard.bash
51820
Public Domain - The Unlicense
You may use this code however you'd like, wherever you'd like, without any requirements, forever.
dddma
, without this step, traffic
cannot be properly forwarded between clients.