How to Set Up a WireGuard VPN Server with Web UI (Ubuntu 24.04)
WireGuard is an extremely fast, modern, and secure VPN protocol built directly into the Linux kernel. By pairing WireGuard with WG-Easy, you get a clean web dashboard to create, manage, and connect VPN clients (PC, Mac, iOS, Android) in seconds via QR codes.
Network Tip: A high-speed VPN requires low ping and unthrottled bandwidth. Our Prepaid KVM Root Servers feature multi-gigabit uplinks through two autonomous systems (AS215136 & AS211066) in Germany and the Netherlands, guaranteeing lightning-fast VPN throughput.
1. Prerequisites & Docker Installation
Ensure Docker is installed and running on your Ubuntu 22.04 / 24.04 server:
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl docker.io docker-compose
sudo systemctl enable --now docker2. Enable IP Forwarding
For your server to route VPN traffic to the internet, enable kernel packet forwarding:
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.d/99-wireguard.conf
echo "net.ipv4.conf.all.src_valid_mark=1" | sudo tee -a /etc/sysctl.d/99-wireguard.conf
sudo sysctl -p /etc/sysctl.d/99-wireguard.conf3. Deploy WG-Easy with Docker
Create a directory for WireGuard data:
mkdir -p ~/wireguard && cd ~/wireguardRun the WG-Easy container (replace <YOUR-SERVER-IP> and YourAdminPassword):
sudo docker run -d --name=wg-easy -e WG_HOST=<YOUR-SERVER-IP> -e PASSWORD_HASH=$(docker run --rm ghcr.io/wg-easy/wg-easy wgpw 'YourAdminPassword') -e PORT=51821 -e WG_PORT=51820 -v ~/.wireguard:/etc/wireguard -p 51820:51820/udp -p 51821:51821/tcp --cap-add=NET_ADMIN --cap-add=SYS_MODULE --sysctl="net.ipv4.conf.all.src_valid_mark=1" --sysctl="net.ipv4.ip_forward=1" --restart unless-stopped ghcr.io/wg-easy/wg-easy4. Firewall Ports (UFW)
Allow the WireGuard VPN tunnel (UDP) and web management dashboard (TCP):
sudo ufw allow 51820/udp
sudo ufw allow 51821/tcp5. Access Web Dashboard & Connect Clients
- Open your browser at:
http://<YOUR-SERVER-IP>:51821 - Log in with your password.
- Click New Client, enter a name (e.g. Smartphone or Laptop), and click Create.
- Scan the QR code with the official WireGuard app on your phone, or download the
.conffile for your PC.
Looking for the right Linux VPS?
Put your project into practice right away: Our KVM VPS provide full root access, lightning-fast NVMe storage, and reliable KVM isolation. Flexible prepaid billing with no subscription and personal Discord support.