WireGuard is one the most popular VPN / traffic proxying applications out there and being so, is very easy to install, here's a simple guide to carry you through the installation & configuration process on Ubuntu 20.04 LTS or higher.
(1) Update & Upgrade Ubuntu Device
Run the following commands in your console:
sudo apt update
sudo apt upgrade
(2) Install the WireGuard VPN server
Simply run the following apt command:
sudo apt install wireguard
(3) Configure the WireGuard server
(3.1) Create a private and public key for the WireGuard server by following these instructions:
Enter the /wireguard Directory:
sudo -i cd /etc/wireguard/
If no /wireguard Directory exists, create it:
mkdir -m 0700 /etc/wireguard/ cd /etc/wireguard/
Now create the keys:
umask 077; wg genkey | tee privatekey | wg pubkey > publickey
If you want to view the keys run these commands:
ls -l privatekey publickey cat privatekey cat publickey
Make sure to store the privatekey safely but where you are able to find it again.
(3.2) Edit the wg0.conf
Start by loading the wg0.conf file:
sudo nano /etc/wireguard/wg0.conf
And make the config changes:
Address = 192.168.6.1/24 (Your VPN server private IP) ListenPort = 41194 (The port you want wireguard to listen on) PrivateKey = EXAMPLE (your WireGuard privatekey)
(4) Configure firewalling for WireGuard on your server:
(4.1) Open the required port
On your KUBBUR Cloud / VPS control panel, enter the "FIREWALL" tab and press "NEW RULE", for this modal to show up:
Enter in any name that you'd like, the Source IP (IP connections are coming from, leave blank for no restrictions), Destination IP (the IP of where your WG server is runnung, in this case it's your VPS IP), Protocol to 'UDP', Source Port (similar to Source IP but the restriction on ports, and the Destination Port (The port in your wireguard config).
(4.2) Apply Wireguard ddos protection filter
Go to back to your KUBBUR "FIREWALL" page and press "FILTERS" for this modal, or similar, to show:
Fill in the details of your WireGuard config and your WireGuard VPN is now a highly DDoS Protected server!
(5) Start WireGuard
To start the WireGuard service run:
sudo systemctl start [email protected]
To make WireGuard service boot on startup run:
sudo systemctl enable [email protected]
And that's how to install WireGuard onto your Ubuntu 20.04 LTS Server.