How to Set Up WireGuard on a VPS in 5 Minutes

Alex VolkovInfrastructure Engineer
··5 min read

WireGuard is the fastest, most modern VPN protocol available today. Unlike OpenVPN or IPSec, it's lightweight, easy to configure, and uses state-of-the-art cryptography. In this guide, we'll set up a WireGuard server on a $4.99/mo Budget VPS.

WireGuard has approximately 4,000 lines of code — compared to OpenVPN's 100,000+. Less code means fewer bugs, a smaller attack surface, and easier auditing.

Prerequisites

  1. A VPS with Ubuntu 24.04 (we recommend 0x.cloud Budget 1 — $4.99/mo)
  2. SSH access to your server
  3. 5 minutes of your time

WireGuard vs Other Protocols

ProtocolSpeedSecuritySetup ComplexityCodebase
WireGuard⚡ FastestChaCha20, Curve25519Easy~4K lines
OpenVPNModerateOpenSSL-basedComplex~100K lines
IPSec/IKEv2FastStrongComplex~400K lines
VLESS+RealityFastTLS 1.3ModerateVaries

Step 1: Install WireGuard

Connect to your server via SSH and run:

sudo apt update && sudo apt install wireguard -y

Step 2: Generate Keys

Generate a private and public key pair for your server:

wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
chmod 600 /etc/wireguard/server_private.key

Important: Never share your private key. The public key is safe to distribute to clients.

Step 3: Configure the Server

Create the WireGuard configuration file:

cat > /etc/wireguard/wg0.conf << EOF
[Interface]
PrivateKey = $(cat /etc/wireguard/server_private.key)
Address = 10.0.0.1/24
ListenPort = 51820
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
EOF

Step 4: Enable IP Forwarding

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p

Step 5: Start WireGuard

sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

Adding Clients

For each client, generate a key pair and add a [Peer] section to wg0.conf. Or use the 0x.cloud dashboard to manage keys automatically — no manual config needed.

Why 0x.cloud?

On 0x.cloud, you can skip all of this. Our VPN plans come pre-configured with WireGuard, VLESS+Reality, Shadowsocks, and OpenVPN — ready in under 60 seconds.

Try it for $4.99/mo →