TTR Networks

Intermediate · WireGuard on Debian: users, routing and keys · section 1 of 10

Why WireGuard, and the lab

✓ Lab-tested 21 October 2026 on Debian 13.7, wireguard-tools 1.0.20210914, nftables 1.1.3

Run a WireGuard server on Debian for several users, an office LAN and a branch: keys, wg-quick and systemd, AllowedIPs as routing and access control, split and full tunnels, roaming and keepalives, adding and removing users live, and the silent failures.

By the end you will be able to:

  • Generate WireGuard keys and run a server as wg-quick@wg0 on Debian, with forwarding and an nftables firewall
  • Explain cryptokey routing: AllowedIPs as both the routing table and the source-address check
  • Route VPN users to an office LAN and a branch LAN, and control user-to-user traffic with the firewall
  • Set up split and full tunnels from the client side, and explain wg-quick's policy routing
  • Add and remove users without a restart, and diagnose a missing handshake, a lost private key and MTU problems

Prerequisites: Linux Network Connectivity

WireGuard is a VPN built into the Linux kernel: small, fast, and configured with little more than a list of public keys, which is why it has become the default choice for new VPNs. This lesson builds a remote-access WireGuard server on Debian for several users, a branch office and an office LAN, using the same lab and the same tasks as the OpenVPN on Debian lesson, so you can compare the two directly. Every output is from a real run.

How it differs from OpenVPN

WireGuardOpenVPN
IdentityOne key pair per device; you list public keysCertificates from your own CA
Removing a userDelete their public key: instantRevoke, publish a CRL, restart
Per-user settingsOne [Peer] block each, on the serverA file per user in ccd/
Who gets which routesThe client's config decidesThe server pushes them
User-to-user trafficAlways through the kernel and the firewallOptionally inside OpenVPN (client-to-client)
Changing networksRoams seamlesslyReconnects
Speed and code sizeIn the kernel, very fast, a few thousand linesUser space, slower, much larger

The trade-off: WireGuard has no certificates, no pushed configuration and very little logging. It's a fast, minimal tunnel, and the management around it (handing out keys and addresses, removing people) is up to you. For connecting two sites between routers, see Site-to-site VPN with WireGuard on VyOS.

The lab

Exactly the OpenVPN lab: the VPN server between the internet (203.0.113.10) and the office LAN, where the office router lanrtr is everyone's gateway; users alice, bob and carol on the internet; a branch router with its own LAN; and a web server that logs each visitor's address. The VPN's own subnet is 10.9.0.0/24, on UDP port 51820.

Diagram: The WireGuard lab — The OpenVPN lesson's lab: three users, an office LAN with its own router, a branch LAN, and a web server that logs every visitor.
  1. Peers over the internet. alice, bob and the branch router send encrypted UDP to the VPN server's public address, 203.0.113.10, port 51820. The first packet triggers a handshake; there's no separate connect step.
  2. Into the office. The server decrypts alice's packet, checks its source (10.9.0.10) is in her AllowedIPs, and forwards it to the office host.
  3. …and the way back. The office host replies to its default gateway, lanrtr. lanrtr needs return routes for 10.9.0.0/24 and 10.20.0.0/24 via the VPN server.
  4. A LAN behind a peer. The branch peer's AllowedIPs on the server includes 10.20.0.0/24. That single line routes the branch LAN to its key, and accepts packets from the branch PCs.
  5. Full tunnel for one user. alice's own AllowedIPs is 0.0.0.0/0, so her internet traffic goes through the tunnel and leaves the VPN server NATed to 203.0.113.10. bob's still goes direct.