No KYC · seven Linux VPS plans, one price in six cities · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Configure a VPS

Guide · VPN · checked 16 November 2026

How do I set up WireGuard on a VPS?

Last updated: · 5 min read

Quick answer

How do I set up WireGuard on a VPS?

To set up WireGuard on a VPS, install the wireguard package, create a key pair for the server and for each device, write /etc/wireguard/wg0.conf, open UDP port 51820 and start wg-quick@wg0. On SaltVPS, the Grain plan (1 vCPU / 2 GB / 40 GB, 2 TB of traffic a month) is sized for a personal tunnel.

In brief
  • Package: wireguard on Debian and Ubuntu; it ships the wg and wg-quick tools.
  • Port: one UDP port, 51820 by convention, open in the firewall.
  • Keys: one private and one public key per side; only public keys are exchanged.
  • Routing: IP forwarding plus a NAT rule let devices browse through the server's IPv4.
  • Server size: the tunnel itself is light; monthly traffic is what to watch.

How do you set up WireGuard on a VPS step by step?

These steps assume Ubuntu 24.04 or Debian 12/13, logged in as root or with sudo.

  1. Install WireGuard

    Run apt update then apt install wireguard. On AlmaLinux or Rocky Linux, run dnf install wireguard-tools.

  2. Create the server keys

    Run umask 077, then wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub. The .key file never leaves the server.

  3. Find the network interface

    Run ip route show default. The word after dev, often eth0 or ens3, is the interface that faces the internet.

  4. Write wg0.conf

    Create /etc/wireguard/wg0.conf with an [Interface] section (Address 10.8.0.1/24, ListenPort 51820, the server private key, a NAT rule) and one [Peer] section per device.

  5. Turn on IP forwarding

    Add net.ipv4.ip_forward=1 to /etc/sysctl.d/99-wireguard.conf, then run sysctl --system.

  6. Open the port and start

    Allow UDP 51820 in the firewall, for example ufw allow 51820/udp. Then run systemctl enable --now wg-quick@wg0.

  7. Add the device and test

    Import the client file into the WireGuard app. Run wg show on the server: a recent handshake line means the tunnel is up.

What goes in each WireGuard file?

Two short files do the whole job: one on the server, one on each device.

Contents of the server and client WireGuard configuration files in a basic IPv4 tunnel
SettingServer wg0.confClient file
Address10.8.0.1/2410.8.0.2/32 (one address per device)
ListenPort51820Not needed
PrivateKeyServer private keyDevice private key
PostUp / PostDowniptables NAT rule on the internet interfaceNot needed
[Peer] PublicKeyDevice public keyServer public key
[Peer] AllowedIPs10.8.0.2/320.0.0.0/0 to send all IPv4 traffic through the VPS
[Peer] EndpointNot neededServer IPv4 followed by :51820
PersistentKeepaliveOptional25, useful behind home routers

What does a working server config look like?

A basic server file holds about ten lines. Replace the key placeholders and the interface name with your own values:

  • [Interface]
  • Address = 10.8.0.1/24
  • ListenPort = 51820
  • PrivateKey = SERVER_PRIVATE_KEY
  • PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  • PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
  • [Peer]
  • PublicKey = LAPTOP_PUBLIC_KEY
  • AllowedIPs = 10.8.0.2/32

If the iptables command is missing on a minimal Debian image, install it with apt install iptables. Each new device gets its own [Peer] block and the next free address, such as 10.8.0.3. After editing, restart the tunnel with systemctl restart wg-quick@wg0.

Which VPS plan fits a WireGuard server?

The smallest plan is usually enough, because WireGuard uses little CPU and almost no memory. The real limit is the monthly traffic, since every byte a device sends or receives crosses the server twice: in and out. SaltVPS checked its plan list on 16 November 2026: traffic runs from 2 TB a month on Grain to 12 TB on Dome, and going past it never adds an automatic charge.

Grain costs $2.25 a month on the 12-month term. A family sharing one tunnel, or heavy video use, points to Flake (4 TB) or Crystal (6 TB). All plans and terms are on the pricing page, and the WireGuard VPS comparison weighs plans for this use.

How do you check that the WireGuard tunnel works?

Look for a handshake on the server, then check the public IP on the device.

  • wg show lists each peer. A line "latest handshake: a few seconds ago" proves the keys match.
  • No handshake at all usually means a closed UDP port or a wrong Endpoint address.
  • A handshake but no web pages points to IP forwarding or the NAT rule.
  • On the device, open any IP-check website. It should show the IPv4 of the VPS.

Keep SSH open while you change firewall rules. The firewall guide shows how to allow SSH first, so a mistake cannot lock you out.

Is WireGuard the best VPN choice for a VPS in 2026?

For a personal or small-team tunnel, WireGuard is the simplest option to run. It has been part of the Linux kernel since version 5.6, so Debian and Ubuntu need no extra modules. Its settings are short, and keys replace certificates. OpenVPN still makes sense where only TCP traffic gets through a network, because WireGuard speaks UDP only.

A fresh server should be hardened first. The Linux VPS security guide lists the steps, starting with SSH keys and a firewall.

WireGuard on a VPS: questions

Which port does WireGuard use?

Any UDP port you set in ListenPort. 51820 is the usual choice; it must be open in the server firewall.

Can several devices share one WireGuard server?

Yes. Give each device its own key pair, its own tunnel address and its own [Peer] block in wg0.conf.

Does WireGuard work on Ubuntu 24.04 and Debian 13?

Yes. Both kernels include WireGuard; apt install wireguard adds the tools. AlmaLinux 10 and Rocky Linux 10 use the wireguard-tools package.

How do I add IPv6 to the tunnel?

Give the server and each peer an IPv6 address in the tunnel, add ::/0 to the client AllowedIPs and forward IPv6 on the server. A SaltVPS server has a routed /64 to draw from.

How do I get the config onto a phone?

Install qrencode on the server and run qrencode -t ansiutf8 < client.conf. Scan the code with the WireGuard app, then delete the file.

Verdict
  • Setting up WireGuard on a VPS takes one package, two short files and one open UDP port.
  • Watch traffic rather than CPU: Grain suits one person, larger plans suit shared tunnels.
Sources (3)
  1. WireGuard quick start — WireGuard project (2026-11-16)
  2. WireGuard installation — WireGuard project (2026-11-16)
  3. wg-quick(8) manual page — Debian (2026-11-16)

Run your own WireGuard server

Grain gives a dedicated IPv4, a routed IPv6 /64 and root over SSH, paid in crypto with no KYC.

From $2.25/mo on 12 months · no KYC

Configure