WireGuard road warrior installer for:
- Ubuntu (18.04, 20.04 and 22.04)
- Debian (10, 11)
- CentOS (7, 8)
- Rocky Linux (8, 9)
- Amazon Linux 2
This script will install automatically the Wireguard server and generate client configuration files for a secure connection.
Note: If you try to run this on a new AWS EC2 instance it will fail. To make it work you have to create the VM without a public IP at first and then add a new Elastic IP later, see this guide.
wget https://raw.githubusercontent.com/besmirzanaj/wg-install/master/wg-install.sh -qO wg.sh && bash wg.sh
git clone https://github.com/besmirzanaj/wg-install.git
cd wg-install
bash wg-install.sh
Initial run will also generate a barcode so you can scan with your phone, android, apple.
To check VPN server and client connectivity status, run wg
on the server.
If you are not satisfied and want to remove the VPN tunnel and kernel changes run the other script:
bash wg-remove.sh
The script can be configured by setting the following environment variables:
- INTERACTIVE - if set to "no", the script will not prompt for user input
- PRIVATE_SUBNET - private subnet configuration, "10.9.0.0/24" by default
- SERVER_HOST - public IP address, detected by default
- SERVER_PORT - listening port, picked random by default
- CLIENT_DNS - comma serparated DNS servers to use by the client
Each subsequent time you run the script after the first initial install, it will now generate additional client config file under $HOME
.
Copy the newly generated configuration files under $HOME
, e.g.: /root/client-wg0.conf
from the wireguard server to your local PC
path (e.g. in Ubuntu: /etc/wireguard/wg0.conf
) and run sudo systemctl start wg-quick@wg0.service
or
you can use the QR code generated by this script on the server terminal to configure mobile clients.
You can also cat
the content of the file and add into your Windows Wireguard client.
Initial run will also generate a barcode so you can scan with your phone. Client downloads:
Each time you run the script again, it will check if the server is already configured, and if yes will only generate new client config files and its encoded qr barcode that can now be scanned from the mobile wireguard client.