Marketplace
Security

WireGuard VPN

Modern, fast VPN with an auto-generated client config.

Deploy this app

About

Installs and configures a WireGuard VPN server using the widely-used community installer, generating the server config and a first client profile automatically.

The client config (QR-code compatible .conf) is saved to /root/wg-client.conf — download it and import it into the WireGuard app.

Ports opened by the installer

51820/udp · WireGuard

Install script (runs as cloud-init user-data on first boot)

#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y wireguard qrencode curl
SERVER_IP=$(curl -s -m 3 https://ifconfig.me || hostname -I | awk '{print $1}')
umask 077
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
wg genkey | tee /etc/wireguard/client_private.key | wg pubkey > /etc/wireguard/client_public.key
SERVER_PRIV=$(cat /etc/wireguard/server_private.key)
CLIENT_PRIV=$(cat /etc/wireguard/client_private.key)
CLIENT_PUB=$(cat /etc/wireguard/client_public.key)
SERVER_PUB=$(cat /etc/wireguard/server_public.key)
cat > /etc/wireguard/wg0.conf <<WG0
[Interface]
Address = 10.66.66.1/24
ListenPort = 51820
PrivateKey = $SERVER_PRIV
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
PublicKey = $CLIENT_PUB
AllowedIPs = 10.66.66.2/32
WG0
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl -p
systemctl enable --now wg-quick@wg0
cat > /root/wg-client.conf <<CLIENT
[Interface]
PrivateKey = $CLIENT_PRIV
Address = 10.66.66.2/24
DNS = 1.1.1.1

[Peer]
PublicKey = $SERVER_PUB
Endpoint = $SERVER_IP:51820
AllowedIPs = 0.0.0.0/0
CLIENT