Complete step-by-step guide for installing and configuring WireGuard

Install WireGuard on Ubuntu VPS (Server)

Step 1: Update and Upgrade System
sudo apt update && sudo apt upgrade -y

Step 2: Install WireGuard
sudo apt install wireguard -y

Step 3: Enable IP Forwarding
Edit sysctl configuration:

sudo vi /etc/sysctl.conf
Uncomment or add:
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

Then apply it with : sudo sysctl -p

Step 4: Generate Server Keys

cd /etc/wireguard/
sudo wg genkey | sudo tee server_private.key | sudo wg pubkey > server_public.key

Step 5: Configure WireGuard Server
Create config file:
sudo vi /etc/wireguard/wg0.conf
Example configuration:

[Interface]
Address = 10.0.0.1/24
PrivateKey =
ListenPort = 51820

Replace with the content of server_private.key.

Step 6: Enable and Start WireGuard
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
sudo systemctl status wg-quick@wg0

Check status:
sudo wg

Leave a Comment

Your email address will not be published. Required fields are marked *