Free tech learning for everyone, from basics to pro

Network SecurityNetworking SecurityIntermediate

WireGuard explained: a simple, modern VPN and how to configure it

In short: WireGuard is a modern VPN protocol with a very small codebase and a fixed set of strong cryptographic algorithms. Each peer has a key pair, like SSH, and a list of AllowedIPs that acts as both routing and access control. It runs over a single UDP port, connects in milliseconds and performs well. It is built into Linux and used by many products, but has fewer enterprise features than IPsec.

Why WireGuard

IPsec and OpenVPN are powerful but complex, with many options that can be configured insecurely. WireGuard, released in 2016 and part of the Linux kernel since 2020, takes the opposite approach: around 4,000 lines of code, one set of modern algorithms (Curve25519, ChaCha20-Poly1305, BLAKE2s, based on the Noise protocol framework), no algorithm negotiation and almost nothing to configure. Its small size makes it easier to audit, and it is fast, especially on mobile devices and small routers.

WireGuard compared with IPsecWireGuardSmall codebase, few optionsModern fixed cryptographyUDP, one portKeys like SSHIPsec / IKEv2Large standard, many optionsNegotiated algorithmsUDP 500/4500 and ESPCertificates or PSKs, very widelysupported
Figure 1. WireGuard is simpler; IPsec is supported by almost every enterprise device.

The key model

Each peer has a private key and a public key. Peers are configured with each other's public keys, much like SSH authorized keys. There are no usernames, passwords or certificates in the core protocol.

wg genkey | tee privatekey | wg pubkey > publickey

A simple server and client

# /etc/wireguard/wg0.conf on the server
[Interface]
Address = 10.99.0.1/24
ListenPort = 51820
PrivateKey = <server private key>

[Peer]
# Laptop of Mohamed
PublicKey = <laptop public key>
AllowedIPs = 10.99.0.2/32

# client config
[Interface]
Address = 10.99.0.2/32
PrivateKey = <laptop private key>
DNS = 10.10.5.53

[Peer]
PublicKey = <server public key>
Endpoint = vpn.example.com:51820
AllowedIPs = 10.10.0.0/16
PersistentKeepalive = 25

Start it with wg-quick up wg0 and check with wg show. Windows, macOS, iOS and Android apps import the same configuration, often as a QR code.

AllowedIPs: routing and access control in one

  • On the sending side, AllowedIPs works like a routing table: traffic to 10.10.0.0/16 goes to this peer. Setting 0.0.0.0/0 sends all traffic through the tunnel (full tunnel).
  • On the receiving side, it is a filter: packets from this peer are only accepted if their source address is in its AllowedIPs.

The server also needs IP forwarding enabled and firewall or NAT rules if clients should reach other networks.

NAT and roaming

WireGuard is silent when there is no traffic, which is good for privacy but means NAT mappings can time out. PersistentKeepalive = 25 on clients behind NAT sends a small packet every 25 seconds to keep the path open. Clients can roam between networks; the server simply learns their new address from the next authenticated packet.

Where you will meet it

  • Built into many routers and firewalls (OPNsense, pfSense, MikroTik, UniFi, FortiGate in some versions).
  • Commercial VPN apps and overlay VPNs such as Tailscale, which add identity login, key distribution and NAT traversal on top of WireGuard.
  • Site-to-site links between cloud and on-premises Linux servers.

Limitations

  • No built-in user authentication, MFA or certificate management; you manage keys yourself or use a product that does.
  • Static internal addresses per peer in plain WireGuard.
  • Uses UDP only, so networks that block all UDP will block it.
  • Less support on traditional enterprise routers than IPsec.

Real-world example: replacing an exposed RDP port

A small accounting firm exposed remote desktop to the internet so two partners could work from home. A consultant replaced it with WireGuard on the office router: one UDP port open, each partner's laptop with its own key, and AllowedIPs limited to the office server. Scans of the office's public address now show nothing useful, and a stolen password alone no longer gives access.

Practice

What does AllowedIPs do on the receiving side?
It filters incoming packets, only accepting those whose source address is in that peer's AllowedIPs.
Why use PersistentKeepalive on a client behind NAT?
WireGuard is silent when idle, so keepalives stop the NAT mapping from timing out.
Name one limitation of plain WireGuard for enterprises.
No built-in user authentication or MFA and manual key management (also UDP only and static peer addresses).

Key takeaways

  • WireGuard is a small, fast VPN with fixed modern cryptography.
  • Peers authenticate with public keys, like SSH.
  • AllowedIPs is both the routing table and the access filter.
  • Products like Tailscale add identity and key management on top.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: