CODE COPIED TO CLIPBOARD!

Easily Install WireGuard VPN on Ubuntu 22/24 with One Command

In this guide, you’ll learn how to install WireGuard VPN on Ubuntu 22.04 and 24.04 using a simple one-command script. This automated setup gets your VPN running in minutes, complete with client configuration and management tools.

Requirements

  • Ubuntu 22.04 or 24.04 server
  • Root or sudo access
  • A VPS or dedicated server with a public IP

What is WireGuard?

WireGuard is a modern VPN protocol designed to be fast, secure, and lightweight. It’s easier to configure than traditional VPN solutions and is built directly into modern Linux kernels.

Script Features

  • One-command install for Ubuntu 22.04 and 24.04
  • Automatic NAT and IP forwarding with interface detection
  • Server key generation and ready-to-use client setup
  • Client configuration saved to /root/client1.conf
  • Optional QR code generation for mobile WireGuard apps

Included Management Tools

  • add-client.sh — add new clients
  • remove-client.sh — remove clients safely
  • list-clients.sh — view existing clients
  • restart-wireguard.sh — restart the VPN service
  • uninstall-wireguard.sh — fully remove WireGuard

Step 1 — Install WireGuard with One Command

wget -O wireguard-vpn.sh https://cdn.xhosts.uk/scripts/wireguard-vpn.sh && chmod +x wireguard-vpn.sh && ./wireguard-vpn.sh

During setup, you’ll be asked whether you want QR code support enabled for quick mobile configuration. Choose yes if you want to connect easily using the WireGuard mobile app.

Step 2 — After Installation

  • Your client configuration will be saved to /root/client1.conf
  • You can import this file into any WireGuard desktop or mobile app
  • Management tools will be available in /root/wireguard/

To add more clients later, run:

cd /root/wireguard
./add-client.sh

Step 3 — Connect Your Device

If QR code support was enabled during installation, you can scan the generated QR code directly using the WireGuard app on iOS or Android for instant setup.

Tip: For best performance, run WireGuard on a low-latency VPS. UK-based servers provide faster speeds and better reliability.

Run WireGuard on a Fast VPS

For the best performance and stability, we recommend running WireGuard on a high-quality VPS. Low latency and reliable networking make a big difference for VPN performance.

Final Thoughts

This script provides a quick and efficient way to deploy a secure WireGuard VPN without dealing with manual configuration.

Built by admins, for admins.