WireGuard
WireGuard is a lean VPN that tunnels IP packets in UDP, with one fixed set of modern cryptography and no negotiation. It is built into Linux, and it powers many commercial VPNs and mesh networks such as Tailscale.
- OSI layer
- 3 Network
- Carried in
- UDP
- Ports
- 51820/udp (default, configurable)
- Specs
- WireGuard whitepaper
- Wireshark filter
wg- Encrypted
- yes
Packet structure
A session starts with a handshake initiation:
Select a field to see what it does.
After the handshake, every tunnelled packet looks like this:
Select a field to see what it does.
How it works
sequenceDiagram
participant A as Peer A
participant B as Peer B :51820
A->>B: Handshake initiation (type 1, 148 bytes)
B->>A: Handshake response (type 2, 92 bytes)
Note over A,B: Session keys derived (Noise IK)
A->>B: Transport data (type 4), first packet confirms the keys
B->>A: Transport data
Note over A,B: New handshake every 2 minutes or 2^60 packets
A->>B: Keepalive (type 4, empty), optional
- Peers and keys: each peer has a Curve25519 key pair. Configuration lists the peers’ public keys and their AllowedIPs (which inner addresses each peer may use and receive). That list is both routing table and access control (“cryptokey routing”).
- Handshake: one round trip based on the Noise IK pattern: both sides authenticate with their static keys and agree on fresh session keys. An optional pre-shared key adds a symmetric layer (post-quantum hedge).
- Data: inner IP packets are encrypted with ChaCha20-Poly1305 and sent as UDP. Peers can roam: the endpoint address is updated from the last authenticated packet.
- Silence: WireGuard sends nothing when there is no traffic (unless persistent keepalive is set, typically every 25 seconds behind NAT), and does not answer unauthenticated packets.
There is no algorithm negotiation and no version field: the crypto is fixed (Curve25519, ChaCha20-Poly1305, BLAKE2s, SipHash, HKDF). A future change would be a new protocol.
In Wireshark
| Filter | Shows |
|---|---|
wg | All WireGuard (default port 51820; use Decode As or enable heuristics for others) |
wg.type == 1 | Handshake initiations (new sessions, every 2 minutes per active tunnel) |
wg.type == 2 | Handshake responses |
wg.type == 3 | Cookie replies: the responder is under load |
wg.keepalive | Keepalives (data messages with an empty payload, 32 bytes) |
wg.receiver_pubkey | Initiations Wireshark could match to a known public key (with keys configured) |
With the peers’ static public keys configured (Preferences › Protocols › WireGuard), Wireshark can tell which peer each initiation is for (it checks MAC1 against each key); with a key log file of the ephemeral private keys it can also decrypt the tunnel.
What normal looks like: a handshake every two minutes per active tunnel, then data. UDP from a workstation to an unknown host on 51820 (or any port) with initiations of exactly 148 bytes and responses of 92 bytes is a WireGuard tunnel, sanctioned or not.
Security notes
- Shadow VPNs: WireGuard, Tailscale and similar tools are easy to install and tunnel past network controls, a known exfiltration and persistence path. Detect them by the fixed handshake sizes and type bytes, or by the coordination servers (e.g.
controlplane.tailscale.com, DERP relays). - Stealth: the server does not answer unauthenticated packets, so port scans do not find it. Good for defenders who run it, bad for those who look for it.
- Key management: private keys sit in plain config files (
/etc/wireguard/wg0.conf); a stolen key lets an attacker impersonate the peer. There is no built-in revocation: remove the peer from every config. - Overly broad AllowedIPs:
0.0.0.0/0on a server-side peer lets a compromised client send traffic as any address inside the tunnel. - Logging: WireGuard itself keeps almost no logs and keeps the last endpoint IP in memory; plan monitoring around the interface.
- No algorithm agility: no downgrade attacks, but also no quick switch if a primitive breaks.
Versions and related
- Linux kernel has included WireGuard since 5.6 (2020); Windows, macOS, BSD and mobile have their own implementations. wireguard-go runs in user space.
- Tailscale, Netbird, Mullvad, Cloudflare WARP and others build mesh or commercial VPNs on it.
- IPsec and OpenVPN are the established alternatives with negotiable crypto.
- Carries IPv4 and IPv6 inside UDP. Like IPsec, it is filed under layer 3 because it tunnels IP packets.
References
- WireGuard whitepaper: protocol and cryptography
- wireguard.com: protocol overview
- Noise protocol framework