# How do you set up WireGuard on a VPS?

> WireGuard VPS setup in 10 minutes: install wireguard, generate keys, write wg0.conf, enable forwarding, open UDP 51820. VR 1 from $4.82/month.

- URL: https://vpsromania.com/guides/how-to-set-up-wireguard-on-a-vps/
- Last updated: 2026-12-01
- Publisher: VPSRomania (https://vpsromania.com)

**Quick answer**

A WireGuard VPS setup takes about ten minutes: install the wireguard package, generate a key pair per device, write /etc/wireguard/wg0.conf, enable IP forwarding and NAT, open UDP port 51820, then start wg-quick@wg0. On **VPSRomania**, a VR 1 server at $4.82 a month, paid in Monero or Bitcoin, carries 2 TB of tunnel traffic.

**In brief**

- **Package**: wireguard on Debian 12/13 and Ubuntu 22.04/24.04; the kernel module is built in.
- **Keys**: one private and one public key per peer, made with wg genkey and wg pubkey.
- **Port**: UDP 51820 by default, the only port to open.
- **Routing**: ip_forward=1 plus a NAT rule so clients reach the internet through the server's IPv4.
- **Plan**: VR 1 for one person, VR 2 for a family's phones and laptops.

## Which plan fits a WireGuard VPN?

WireGuard needs almost no CPU or memory; traffic is what runs out first. Every plan includes one IPv4 and a /64 of IPv6.

*VPSRomania plans for a self-hosted WireGuard VPN, traffic and prices of 30 November 2026*

| Plan | Monthly traffic | Monthly price | Fits |
| --- | --- | --- | --- |
| VR 1 | 2 TB | $4.82 | One person, phone and laptop |
| VR 2 | 4 TB | $5.44 | A household, 5 to 10 devices |
| VR 4 | 8 TB | $9.08 | A small team or heavy streaming |

Traffic counts on a shared 1 Gbit/s port. Plans under $15 a month are rented 3 months at a time.

## How to install and start WireGuard on the server?

1. **Install the tools** — Run apt install wireguard iptables qrencode. The module ships in the Debian and Ubuntu kernels.
2. **Generate the server keys** — In /etc/wireguard, with umask 077, run wg genkey and pipe it into wg pubkey to save server.key and server.pub.
3. **Write wg0.conf** — Give the tunnel a private range (10.8.0.1/24), the listen port 51820, the private key and NAT rules on the interface that holds the default route.
4. **Enable forwarding** — Set net.ipv4.ip_forward=1 in /etc/sysctl.d/99-wireguard.conf and load it with sysctl --system.
5. **Open the port and start** — Run ufw allow 51820/udp, then systemctl enable --now wg-quick@wg0. Check with wg show.
6. **Add each device** — Create a key pair per client, add a [Peer] block with its public key and a /32 address, restart the tunnel, then import the client file or scan its QR code.

*Server: install, keys, forwarding (Debian or Ubuntu, as root)*

```bash
apt install -y wireguard iptables qrencode
cd /etc/wireguard && umask 077
wg genkey | tee server.key | wg pubkey > server.pub
wg genkey | tee phone.key | wg pubkey > phone.pub
ip route show default        # note the interface name, e.g. eth0 or ens3
echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/99-wireguard.conf
sysctl --system
```

*/etc/wireguard/wg0.conf on the server (replace eth0 and the keys)*

```ini
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = CONTENT_OF_server.key
PostUp = iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

[Peer]
# phone
PublicKey = CONTENT_OF_phone.pub
AllowedIPs = 10.8.0.2/32
```

*phone.conf, the client file (import it, or show it as a QR code with: qrencode -t ansiutf8 < phone.conf)*

```ini
[Interface]
PrivateKey = CONTENT_OF_phone.key
Address = 10.8.0.2/32
DNS = 9.9.9.9

[Peer]
PublicKey = CONTENT_OF_server.pub
Endpoint = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
```

*Open the port, start at boot, check the handshake*

```bash
ufw allow 51820/udp
ufw route allow in on wg0 out on eth0
systemctl enable --now wg-quick@wg0
wg show
```

## Why is WireGuard the best VPN protocol for a small VPS?

**WireGuard is a few thousand lines of code in the Linux kernel, uses one UDP port, and reconnects without a visible pause when a phone changes network.** OpenVPN runs in user space, needs certificates and a dozen options, and uses more CPU per megabit. On a 1 vCPU server, WireGuard can push several hundred megabits per second, well beyond what a home connection consumes. Its keys are short strings you can paste, so adding a device takes a minute. The cost is flexibility: it has no user names or passwords, only keys, and it does not try to look like other traffic.

## What does a personal VPN on a VPS hide, and what not?

**It hides your traffic from the local network and your internet provider, and shows the server's IPv4 to the sites you visit; it does not make you unknown.** That address belongs to you alone, so sites can link your sessions over time, and VPSRomania sees the volume and timing of the tunnel. Romania is in the EU, Iceland is in the EEA, Switzerland is outside both: each answers to its own courts. Complaints about traffic leaving the server arrive at the provider of that IP, and outgoing port 25 is closed on every server. Read [wireguard vpn](https://vpsromania.com/use-cases/wireguard-vpn/ "Run a WireGuard VPN on a Romania VPS") for the trade-offs against a commercial VPN.

## Which city gives the best WireGuard speed?

**Pick the city nearest to you on the network, not on the map.** Published medians read on 30 November 2026 put Zurich 22 ms from Frankfurt, Reykjavik 35 ms from London and Bucharest 24 ms from Kyiv (WonderNetwork, hourly pings between probe servers). [romania vps latency](https://vpsromania.com/romania-vps-latency/ "Romania VPS latency to European cities") lists ten cities. According to VPSRomania's survey of 30 November 2026, the median monthly price of a 1 vCPU / 1 GB crypto VPS in Iceland was $8.62 across 8 hosts; VR 1 in Reykjavik costs $4.82, details on the [iceland vps](https://vpsromania.com/iceland-vps/ "Iceland VPS paid in crypto") page.

## How do you keep the tunnel safe once it runs?

**Treat each client key like a password, give every device its own key, and remove a lost device's [Peer] block at once.** Keep unattended upgrades on so the kernel and wireguard-tools stay patched. The [ufw firewall vps](https://vpsromania.com/guides/how-to-set-up-a-firewall-with-ufw/ "How to set up a firewall with ufw") guide explains the forward rule used above. If a client connects but cannot browse, check that ip_forward is 1, that the NAT rule names the right interface, and that the handshake time in wg show is recent.

## WireGuard VPS questions

### How much RAM does a WireGuard VPS need?

Very little: the tunnel itself uses a few megabytes. 1 GB on VR 1 leaves room for a DNS filter such as AdGuard Home or Pi-hole next to it.

### Can I route IPv6 through the tunnel too?

Yes: add an IPv6 address from a private fd00::/8 range on both sides, enable net.ipv6.conf.all.forwarding and add the ip6tables MASQUERADE rule. Every plan also has a public /64.

### Which port should WireGuard use if 51820 is blocked on my network?

Any free UDP port works; 443/udp often passes restrictive networks. Change ListenPort, the Endpoint and the ufw rule together.

### Is a self-hosted WireGuard VPN legal in Romania, Iceland and Switzerland?

Yes, running a VPN server is legal in all three countries. What is sent through it remains subject to the law and the acceptable use policy.

### What is a low-cost way to run WireGuard for a family?

VR 2 at $5.44 a month, or $4.24 a month on a 12-month term, with 4 TB of traffic shared by every device.

**Verdict**

- WireGuard is the simplest VPN to host yourself: one package, one UDP port, one key per device.
- VR 1 covers one person; choose the city by measured latency, since the price is the same in all three.

## Host your own WireGuard endpoint

VR 1 in Reykjavik: 1 vCPU, 1 GB RAM, 2 TB of traffic, $13.73 for 3 months.

[Deploy VR 1 in Reykjavik — $4.82/mo](https://vpsromania.com/app/checkout/?plan=vr-1&location=is-rkv&term=3m&from=guides-how-to-set-up-wireguard-on-a-vps&lang=en)

## Sources

1. [WireGuard quick start](https://www.wireguard.com/quickstart/) — WireGuard (read 30 Nov 2026)
2. [wg-quick(8) manual page](https://manpages.debian.org/bookworm/wireguard-tools/wg-quick.8.en.html) — Debian (read 30 Nov 2026)
3. [WireGuard whitepaper](https://www.wireguard.com/papers/wireguard.pdf) — Jason A. Donenfeld (read 30 Nov 2026)
4. [Global ping statistics, Bucharest, Reykjavik and Zurich pairs](https://wondernetwork.com/pings) — WonderNetwork (read 30 Nov 2026)

---

VPSRomania: VPSRomania is a VPS host with KVM servers in Bucharest, Romania, and in Reykjavik and Zurich for buyers who want Iceland or Switzerland, paid only in cryptocurrency, Monero included, without any identity check. Plans start at $4.82 a month. VPSRomania LLC, a New Mexico company, runs it.
