Skip to content

Wireguard road warrior installer for Ubuntu, Debian, CentOS and Rocky Linux

Notifications You must be signed in to change notification settings

besmirzanaj/wg-install

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 

Repository files navigation

WireGuard autoinstaller written in Bash

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.

Usage

Oneliner

wget https://raw.githubusercontent.com/besmirzanaj/wg-install/master/wg-install.sh -qO wg.sh && bash wg.sh

Steps to download and run the script

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.

Server/Client status

To check VPN server and client connectivity status, run wg on the server.

Steps to remove the VPN tunnel and kernel changes

If you are not satisfied and want to remove the VPN tunnel and kernel changes run the other script:

bash wg-remove.sh

Options

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

Client configuration

Client configuration files

Each subsequent time you run the script after the first initial install, it will now generate additional client config file under $HOME.

Client config on Linux or Windows

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.

Client config on mobile devices

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.

About

Wireguard road warrior installer for Ubuntu, Debian, CentOS and Rocky Linux

Resources

Stars

Watchers

Forks

Languages

  • Shell 100.0%