WireGuard: set up your own VPN on a VPS, step by step

11 min read

Bundle of glowing fiber optic cables in the dark

WireGuard explained: what this free VPN is, why to run it on a VPS, how to configure it step by step on Debian or Ubuntu, connect your devices and keep it secure over time.

By Mouhamed BANKOLE, CEO at ITNET Technologies · Updated November 25, 2026 · Reading time: 10 min

You want to reach your company's tools while working remotely, secure your connection on hotel Wi-Fi or link two offices, without relying on a consumer VPN service. WireGuard lets you set up your own VPN in half an hour, on a small server you control. But between keys, internal addresses and the firewall, the first setup can be confusing. This guide explains what WireGuard is, why to run it on a VPS, how to configure it step by step and how to keep it secure over time.

In short

  • WireGuard is a free, simple and fast VPN protocol that encrypts traffic inside a UDP tunnel, according to its official website.
  • It has been part of the Linux kernel since version 5.6, in March 2020, according to Wikipedia.
  • A small Linux VPS is enough for a few users: the server only needs one open UDP port, 51820 by default.
  • Installation takes four steps: install the package, generate the keys, write the wg0.conf file, start the interface.
  • Official clients exist for Windows, macOS, Android and iOS, according to the installation page.

Contents

  1. What is WireGuard?
  2. Why run your own VPN on a VPS?
  3. WireGuard, OpenVPN or IPsec: which one should you choose?
  4. What VPS do you need for a WireGuard server?
  5. How do you install WireGuard on a Linux VPS?
  6. How do you configure the WireGuard server?
  7. How do you connect a computer or a smartphone?
  8. How do you secure and maintain a WireGuard VPN?
  9. What are the limits of a personal VPN?

What is WireGuard?

WireGuard is free VPN software that creates an encrypted tunnel between two machines by simply exchanging public keys, just as you would with SSH (WireGuard). It was designed to be simpler and faster than IPsec and OpenVPN.

Its main features:

  • key-based operation: each machine has a private key and a public key, and knows its peers' public keys (WireGuard);
  • modern, fixed cryptography: Curve25519, ChaCha20, Poly1305 and BLAKE2, with no algorithm to choose (WireGuard);
  • UDP-only transport, port 51820 by default (Wikipedia);
  • a regular network interface, named wg0, managed with the usual Linux tools (WireGuard);
  • short, auditable code, designed to be reviewed by a single person (WireGuard).

The protocol was also formally verified in a proof published in May 2019 by researchers at INRIA, according to Wikipedia.

Why run your own VPN on a VPS?

A VPN on your own VPS gives you encrypted access to your resources and a fixed IP address that only you use. You share neither the infrastructure nor the logging policy of a consumer VPN provider.

The most common uses:

  • remote work: reach an internal server, a database or an admin tool without exposing it to the Internet;
  • public Wi-Fi: encrypt all your traffic at the hotel, the train station or a trade show;
  • a fixed IP for allowlists: a supplier, a bank or a back office that only accepts certain IP addresses;
  • linking sites: connect two offices, or an office and remote servers;
  • administering your servers: close SSH to the public and only open it through the VPN.

Pro tip: for server administration, a WireGuard VPN lets you keep a single UDP port open to the Internet. Every other service stays invisible from the outside.

WireGuard, OpenVPN or IPsec: which one should you choose?

For a new VPN on a Linux VPS, WireGuard is the simplest choice: short configuration, fixed cryptography and integration into the Linux kernel (WireGuard). OpenVPN and IPsec still make sense in specific cases.

CriterionWireGuardOpenVPNIPsec (strongSwan)
TransportUDP onlyUDP or TCPUDP (IKE, ESP)
Authenticationpublic keyscertificates, credentialscertificates, pre-shared keys
Algorithm choicefixed by the protocolconfigurableconfigurable
Linux integrationin the kernel since 5.6user-space softwarein the kernel
Configuration complexitylowmediumhigh
When it winsnew VPN, mobile, simple site-to-sitenetworks that block UDPinteroperability with corporate firewalls

Sources: WireGuard website and Wikipedia for WireGuard; general characteristics of OpenVPN and IPsec.

What to take from the table:

  • WireGuard only uses UDP (Wikipedia): on a network that blocks everything but the web, OpenVPN over TCP may get through where WireGuard fails;
  • WireGuard does not handle key distribution or user accounts (WireGuard): beyond a few dozen users, plan a management tool on top.

What VPS do you need for a WireGuard server?

An entry-level Linux VPS is enough for a WireGuard VPN used by one person or a small team: encryption is light and the server stores nothing. What matters most is bandwidth, location and the ability to open a UDP port.

The criteria to choose:

  • location: a server in France gives a French IP and low latency from France;
  • a recent distribution: Debian or Ubuntu install WireGuard with a single command (WireGuard);
  • a configurable firewall to open the VPN's UDP port;
  • root access to configure routing.

On the Wayhost VPS offer, checked on 11/25/2026:

PlanResourcesPrice checked on 11/25/2026 (excl. VAT, 12-month term)WireGuard use
KVM11 vCPU, 4 GB RAM, 50 GB SSD€7.40/month (€88.83/year)personal VPN or small team
KVM22 vCPU, 8 GB RAM, 100 GB SSD€9.68/month (€116.19/year)team VPN plus other services on the same server

The same page lists full root access, security groups to filter inbound and outbound traffic, and deployment zones in Cergy (France) and Helsinki (Finland) (Wayhost VPS, checked on 11/25/2026). To understand what a virtual server covers, see our guide What is a VPS?.

How do you install WireGuard on a Linux VPS?

On Debian or Ubuntu, the command apt install wireguard installs the module and the tools (WireGuard). On Fedora, the package is called wireguard-tools.

The steps, over SSH on your VPS:

  1. Update the system, then install WireGuard:
sudo apt update && sudo apt upgrade -y
sudo apt install wireguard
  1. Generate the server key pair with the wg tool, restricting file permissions (WireGuard):
cd /etc/wireguard
umask 077
wg genkey | tee server_private.key | wg pubkey > server_public.key
  1. Generate one key pair per client device the same way, with a different file name for each.
  2. Enable IPv4 forwarding so the server can relay client traffic:
echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-wireguard.conf
sudo sysctl --system
  1. Find the name of your public network interface with ip route (often eth0 or ens3): you will need it in the configuration.

How do you configure the WireGuard server?

The configuration lives in a /etc/wireguard/wg0.conf file that describes the server interface, followed by one block per authorized client device. The wg-quick tool reads this file and brings the interface up (WireGuard).

Sample server file (replace the keys and, if needed, eth0 with your interface name):

[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 = CLIENT_1_PUBLIC_KEY
AllowedIPs = 10.8.0.2/32

What each line does:

  • Address: the server's address on the VPN's private network;
  • ListenPort: the UDP listening port, 51820 by default (Wikipedia);
  • PostUp and PostDown: the address translation (NAT) that lets clients reach the Internet through the server;
  • [Peer]: one block per device, with its public key and the unique address it will receive.

Then start the interface and enable it at boot:

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

Finally, open UDP port 51820 in the server firewall and in your host's security groups.

How do you connect a computer or a smartphone?

Install the official WireGuard app, available for Windows, macOS, Android and iOS (WireGuard), then import a client configuration file. On Linux, the same file is started with wg-quick.

Sample client file:

[Interface]
PrivateKey = CLIENT_1_PRIVATE_KEY
Address = 10.8.0.2/32
DNS = 9.9.9.9

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = VPS_IP_ADDRESS:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25

The settings to understand:

  • AllowedIPs = 0.0.0.0/0, ::/0 sends all traffic through the VPN; use only 10.8.0.0/24 to reach just the internal network;
  • PersistentKeepalive = 25 keeps the tunnel open behind NAT or a firewall, 25 seconds being the interval recommended by the WireGuard documentation;
  • QR code: on a smartphone, generate a QR code of the file with qrencode to import it without retyping.

Then check the connection with sudo wg show on the server: a "latest handshake" line should appear for the client.

How do you secure and maintain a WireGuard VPN?

A well-run WireGuard VPN rests on three rules: one key per device, an up-to-date server and a firewall closed to everything except the VPN port. WireGuard is simple, but the server that hosts it is still an exposed server.

Best practices:

  • one key pair per device, never shared: a lost phone is revoked by removing its [Peer] block;
  • protected private keys: 600 permissions on the files, never sent by plain email;
  • SSH reachable only through the VPN once the tunnel works, with key-based authentication;
  • regular updates of the system and the WireGuard package;
  • an encrypted backup of /etc/wireguard, stored off the server;
  • an optional pre-shared key (PresharedKey) for an extra layer of symmetric encryption, which Wikipedia presents as a hedge against future quantum computers.

For a growing team, a dedicated server can host the VPN alongside other internal services, and a domain name with a subdomain such as vpn.your-company.com avoids reconfiguring every client if the server IP changes.

What are the limits of a personal VPN?

A VPN on your VPS encrypts your traffic up to the server, but it does not make you anonymous: all traffic leaves with the VPS IP, which is registered to you. It is a security and access tool, not an anonymity tool.

The limits to know:

  • a single exit IP address, the VPS's, in the country where it is hosted;
  • you are the administrator: updates, backups and monitoring are your job;
  • UDP may be blocked on some corporate or hotel networks;
  • no built-in account management: beyond a few dozen users, manually managing [Peer] blocks gets heavy.

If your need is mainly to publish a website or an application, a VPS alone is enough, with no VPN; our article on the sovereign VPS explains what to look for.

FAQ

Is WireGuard free?

Yes, WireGuard is free and open source software, released under the GPLv2 license for its Linux kernel part. You only pay for the server that hosts it. The official apps for Windows, macOS, Android and iOS are free as well.

Is WireGuard faster than OpenVPN?

WireGuard is designed to perform considerably better than OpenVPN, in particular because it runs in the Linux kernel and uses very fast encryption algorithms. The real gain depends on the server and the network. In everyday use, the difference is most noticeable when connecting, which is almost instant.

Which port does WireGuard use?

WireGuard uses a UDP port, 51820 by default. You can choose another one with the ListenPort line of the configuration file. Remember to open this port in the server firewall and at your hosting provider.

Can you use WireGuard on Windows?

Yes, there is an official app for Windows, as well as for macOS, Android and iOS. You just import or paste the client configuration file. The server itself ideally runs on Linux.

How many users can a WireGuard VPN handle?

Technically, a WireGuard server can handle many peers, each with its own [Peer] block and internal address. The practical limit is mostly manual key management. Beyond a few dozen devices, a peer management tool makes life easier.

Does WireGuard make you anonymous?

No, WireGuard encrypts traffic between your device and the server, but everything then leaves with the server's IP address, which is tied to your hosting account. It protects you on public Wi-Fi and gives you a fixed IP. It is not an anonymity tool.

Do you need a powerful VPS for WireGuard?

No, an entry-level VPS is enough for a personal VPN or a small team, because WireGuard's encryption uses few resources. Look instead at bandwidth, location and the ability to open a UDP port. Keep some headroom if the server hosts other services.

Key takeaways

  • WireGuard is a free, fast and simple VPN, based on exchanging public keys, just like SSH.
  • It has been in the Linux kernel since version 5.6 and installs with apt install wireguard on Debian and Ubuntu.
  • A small VPS is enough: four steps (package, keys, wg0.conf, start) and one open UDP port.
  • One key per device, a closed firewall, an up-to-date server: those are the three security rules.
  • A personal VPN protects you and gives you a fixed IP, it does not make you anonymous.

To run your WireGuard VPN on a server hosted in France, with root access and security groups, explore the Wayhost VPS plans.

Article written by Mouhamed BANKOLE, CEO at ITNET Technologies.

Have a specific question?

Our step-by-step articles answer the most common questions.

Knowledge base