• Welcome to TalkativeTurtles - a community for developers & tech enthusiasts.
  • Share projects, get code reviewed, and talk tech without the noise.
  • New here? Introduce yourself in the Introductions forum!
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Title: [Tutorial] Setting up a WireGuard VPN on a cheap VPS - complete guide
Threaded Mode
#1
WireGuard is the cleanest way to get a private tunnel between your devices and a server you control. This guide covers setting up a WireGuard server on a Debian/Ubuntu VPS and connecting a Linux client. Adapt for other OS as needed.

Prerequisites
  • A VPS running Debian 12 or Ubuntu 22.04+ (any cheap £3-5/mo provider works)
  • Root or sudo access
  • Your server's public IP address

Step 1: Install WireGuard on the server
Code:
sudo apt update && sudo apt install wireguard -y

Step 2: Generate server keys
Code:
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
chmod 600 /etc/wireguard/server_private.key

Step 3: Create server config at /etc/wireguard/wg0.conf
Code:
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server_private_key>

PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.0.0.2/32

Step 4: Enable IP forwarding
Code:
echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Step 5: Start and enable the service
Code:
sudo systemctl enable --now wg-quick@wg0

Step 6: On the client
Install WireGuard, generate a client keypair the same way, then create /etc/wireguard/wg0.conf:
Code:
[Interface]
Address = 10.0.0.2/24
PrivateKey = <client_private_key>
DNS = 1.1.1.1

[Peer]
PublicKey = <server_public_key>
Endpoint = <server_ip>:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

Bring it up with sudo wg-quick up wg0 and check the connection with sudo wg show.

Set AllowedIPs = 10.0.0.0/24 instead of 0.0.0.0/0 if you only want LAN access rather than routing all traffic through the VPN.

Questions welcome - happy to help troubleshoot.
Reply
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tutorial] SSH keys - setup, security, and useful config tricks Zero Two 0 205 06-22-2026, 02:31 PM
Last Post: Zero Two
  [Tutorial] Essential Git commands and workflows every developer should know Zero Two 0 206 06-22-2026, 02:09 PM
Last Post: Zero Two
  [Index] Community Tutorial & Resource Index Zero Two 0 214 06-21-2026, 09:42 AM
Last Post: Zero Two

Forum Jump:


Browsing: 2 Guest(s)