Skip to content

Setting up a WireGuard VPN on a VPS

By Onehost Team1 min read

WireGuard is a fast, modern, and remarkably simple VPN. Running it on a VPS gives you a private, encrypted tunnel for secure browsing or accessing internal services.

1. Install

sudo apt install wireguard -y

2. Generate keys

wg genkey | tee privatekey | wg pubkey > publickey

3. Configure the server

Create /etc/wireguard/wg0.conf with the server's private key, a VPN subnet (e.g. 10.0.0.1/24), and a [Peer] block for each client's public key. Enable IP forwarding and add a firewall rule to allow the WireGuard port (default 51820/UDP).

4. Start it

sudo systemctl enable --now wg-quick@wg0
sudo wg show

5. Connect a client

Install the WireGuard app on your device, add the server's public key and endpoint, and connect. WireGuard's small codebase and modern cryptography make it both faster and easier to audit than older VPNs. A Onehost VPS with an Indian IP address works well as a low-latency personal VPN in India.

Put it into practice

A KVM Linux VPS with full root access, billed in rupees.

Linux VPS plans