Launch offer: -50% for your first 3 months with code LANCEMENT — new customers, VPS, first 50 orders, until 31 Dec 2026. See the VPS plans →
FranceHosta RootLab service
Please note: ordering, the customer area and our terms are currently available in French only.
Practical guide

WireGuard on a VPS: link your devices in a private network

WireGuard is a modern VPN that is fast and simple to configure. Installed on a VPS, it links your computers, your phone and your homelab in a single encrypted private network, wherever you are.

What will your VPN be used for?

With WireGuard, each device gets a private address (here in 10.8.0.x) and can reach the others through this encrypted tunnel, even behind a home router or on a mobile network. Typical uses: reaching your NAS or home automation from outside, administering your servers without exposing them to the Internet, linking two sites, or restricting your VPS's SSH access to the VPN alone.

What this guide does not cover: sending all your Internet browsing out through the VPS (a "full tunnel" VPN). Our VPS plans only have an IPv6 address and no IPv4: sites that are still IPv4-only would not be reachable that way. For a private network between your own machines, though, IPv6 alone is no problem at all.

Choose a KVM VPS

WireGuard runs in the Linux kernel. On a KVM VPS you have your own kernel and everything works straight away. On LXC, the kernel is shared with our server and WireGuard is not guaranteed: choose KVM for this project (see KVM or LXC). In terms of power, the VPS Mini is enough for personal or family use.

Your devices also need IPv6 to reach the VPS. Most French home routers and mobile plans have it; the IPv6 VPS guide explains how to check.

1. Install WireGuard on the VPS

apt update && apt install -y wireguard

Generate the server's key pair. umask 077 ensures the private key is readable by root only:

cd /etc/wireguard
umask 077
wg genkey | tee server.key | wg pubkey > server.pub

2. Generate each device's keys

Each device has its own key pair. The easiest way is to generate them in the device's WireGuard app (Windows, macOS, Android, iOS): it displays the public key for you to copy. On Linux, use the same command as above.

3. Configure the server

Create /etc/wireguard/wg0.conf:

[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = <contents of server.key>

# Laptop
[Peer]
PublicKey = <laptop public key>
AllowedIPs = 10.8.0.2/32

# Phone
[Peer]
PublicKey = <phone public key>
AllowedIPs = 10.8.0.3/32

Add one [Peer] block per device, each with its own address. So that devices can reach each other through the VPS, allow routing:

echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/90-wireguard.conf
sysctl --system

If you use a firewall such as ufw, open WireGuard's port:

ufw allow 51820/udp
ufw route allow in on wg0 out on wg0

The second rule lets traffic pass from one device to another through the VPS, which ufw blocks by default.

Start the VPN and enable it at boot:

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

4. Configure a device

In the WireGuard app, create a tunnel with this configuration (example for the laptop):

[Interface]
PrivateKey = <laptop private key>
Address = 10.8.0.2/24

[Peer]
PublicKey = <contents of server.pub>
Endpoint = [2001:db8::10]:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25

Replace 2001:db8::10 with your VPS's IPv6 address, keeping the square brackets. The AllowedIPs = 10.8.0.0/24 line only sends private-network traffic through the tunnel: the rest of your connection is unchanged. PersistentKeepalive keeps the tunnel open behind a home router or a mobile network.

Enable the tunnel, then test from the device:

ping 10.8.0.1

If the VPS replies, you are done. The wg show command on the server shows, for each device, the time of the last exchange ("latest handshake").

5. Going further: SSH through the VPN only

Once the VPN is in place, you can allow SSH only from the private network. With ufw, for example:

ufw allow from 10.8.0.0/24 to any port 22 proto tcp

Do not remove the SSH rule that is open to everyone until you have checked that the connection through the VPN works (ssh root@10.8.0.1): otherwise you risk locking yourself out.

Frequently asked questions

Does WireGuard work on LXC?

It is not guaranteed: WireGuard depends on the kernel, which is shared in LXC. Choose a KVM VPS, which has its own kernel. See KVM or LXC.

Can I send all my browsing through the VPS?

Not for IPv4 sites: our VPS plans only have an IPv6 address. WireGuard on our VPS plans is meant for a private network between your devices, not for going out onto the Internet with the server's address.

Can my phone connect?

Yes, with the official WireGuard app for Android or iOS, as long as the phone's network has IPv6. That is the case with most French mobile plans.

How many devices can I link?

As many as you like, within the limit of the addresses in the private network you choose (253 with a /24). Simply add one [Peer] block per device.

Your own VPN, on a server in France

KVM VPS with root access, SSD and ECC RAM, from €1.49 a month.