Guide

How to set up a WireGuard VPN server

WireGuard is the fastest, simplest modern VPN protocol — kernel-integrated, sub-100 line audit surface, and much faster than OpenVPN. Hostiger offers pre-configured WireGuard VPS plans from $15/mo. This guide covers both the pre-configured path and manual setup on any Linux VPS.

Estimated time: 10 minutes
Cost: from $15/mo
Updated: 2026-07-14
1

Provision a WireGuard VPS

Fastest path: order a Hostiger WireGuard VPS from $15/mo. WireGuard is pre-installed, IP-forward is enabled, and firewall rules are set up. Skip to step 5 if you use this path.

2

Manual: install WireGuard

On any Ubuntu 22.04/24.04 VPS, run apt update && apt install wireguard-tools -y. Verify with wg --version.

3

Manual: generate keys

Run wg genkey | tee privatekey | wg pubkey > publickey. This creates the server's key pair. Copy privatekey and publickey content to a safe place — you'll need both.

4

Manual: create /etc/wireguard/wg0.conf

Create the config with an internal subnet (10.8.0.0/24), the server's private key, and a listen port (51820). Add PostUp and PostDown rules for NAT masquerading on your public interface.

5

Enable IP forwarding + start the tunnel

Set net.ipv4.ip_forward=1 in /etc/sysctl.conf, then sysctl -p. Start the tunnel with systemctl enable --now wg-quick@wg0.

6

Add a client peer

Generate a client key pair on your laptop. Add a [Peer] block to wg0.conf with the client's public key and its AllowedIPs (e.g., 10.8.0.2/32). Restart the tunnel: systemctl restart wg-quick@wg0.

7

Create the client config

Create a config file for the client with the client's private key, the server's public key, endpoint (server-ip:51820) and DNS (1.1.1.1). Import into the WireGuard app on iOS/Android/macOS/Windows/Linux.

8

Test the tunnel

Activate the tunnel on the client. Visit ipleak.net — you should see the Hostiger VPS IP as your public IP. Run wg show on the server to confirm the handshake.

Ready to try it?

Deploy a Hostiger VPS in under 60 seconds and put this guide into action.

Get a WireGuard VPS