WireGuard is a free, open-source VPN that has been built into the Linux kernel since 2020. On a Linux server of your own it takes a handful of commands and two short configuration files to give your laptop and phone an encrypted tunnel to that server. Beyond protecting you on public Wi-Fi, the tunnel lets you keep private services, such as a mail server's administration pages, reachable only by your own devices.
A VPN (virtual private network) creates an encrypted connection between two machines over the internet. Everything sent through it is unreadable to the networks in between.
WireGuard does this with a small, modern design:
Each device in a WireGuard network is identified by a public key, much like an SSH key. Each side lists the other's public key and the addresses it may use, a setting called AllowedIPs, which acts as both the route and the access list.
This is the shape of the job, so you know what is involved. Test each step before relying on it.
On Debian and Ubuntu:
sudo apt install wireguard
wg genkey | tee privatekey | wg pubkey > publickey
The private key never leaves the machine it was made on. Only public keys are exchanged. The phone and desktop apps generate their own keys for you.
The server's file, /etc/wireguard/wg0.conf, names its own private key, its address inside the VPN and the port it listens on, then one [Peer] section per device:
[Interface]
PrivateKey = <server private key>
Address = 10.8.0.1/24
ListenPort = 51820
[Peer]
PublicKey = <laptop public key>
AllowedIPs = 10.8.0.2/32
Port 51820 is the usual choice, not a built-in default; WireGuard picks a random port if you do not set one.
The device's file mirrors the server's: its own private key and address, then the server's public key, the server's public address and port as the endpoint, and the addresses to send through the tunnel. Setting AllowedIPs to the VPN range sends only VPN traffic through the tunnel; setting it to 0.0.0.0/0 sends everything, which is what you want on public Wi-Fi.
Allow the chosen UDP port in the server's firewall, then start WireGuard and enable it at boot:
sudo ufw allow 51820/udp
sudo systemctl enable --now wg-quick@wg0
If devices are to send all their traffic through the server, the server also needs IP forwarding switched on, in a file under /etc/sysctl.d/, and a NAT rule. On Debian 13 the old /etc/sysctl.conf file is no longer read.
Remember that a VPN runs both ways: a device on the VPN can reach the server, and the server can reach the device. Firewall the WireGuard interface as carefully as the public one.
A VPN is most useful when it lets you close doors. A mail server has to keep port 25 open to receive mail from the rest of the world, but its administration pages, and even webmail and IMAP if your users are all on the VPN, need not be open to everyone.
Mailcow, the open-source mail server, runs in Docker. Its documentation warns that ordinary host firewall rules on the INPUT chain do not restrict it, because Docker manages its own rules, and that restrictions belong in the DOCKER-USER chain. Mailcow can also bind its services to a chosen IP address. Combined with WireGuard, that lets you make the administration interface answer only on the VPN. Mailcow documents these building blocks rather than a ready recipe, so plan and test the result.
A Noiz Cloud server gives you the root access and Linux system WireGuard needs. If you would rather Noiz did the Linux side, Linux administration is quoted by the hour, once off or maintained monthly.
If you run a mail server and want its private pages reachable only from your own devices, get in touch.
Note: while some of this content was produced with the help of AI, the final editing has been done by a real human being.