toolhq.io

All posts
7 min readby Jameel Haider

WireGuard vs OpenVPN: what goes in a client config file

A VPN client config is a small text file, but every line controls how and where your traffic is tunneled. WireGuard and OpenVPN, the two dominant protocols, take very different approaches, and the config reflects that.

The core difference

WireGuard is deliberately minimal: a few thousand lines of code, modern cryptography with no algorithm choices to misconfigure, and a config that fits on a postcard. It runs over UDP and is fast to connect. OpenVPN is older, far more configurable, can run over TCP or UDP, and is more flexible at traversing restrictive networks, at the cost of a heavier, more complex setup.

For most new deployments WireGuard is the simpler, faster default; OpenVPN earns its place where you need its flexibility or are stuck on a hostile network.

WireGuardOpenVPN
TransportUDP onlyUDP or TCP
Config sizeA dozen linesDozens, plus certs
Crypto choicesFixed, modernConfigurable
Connect speedNear instantSlower handshake
Firewall evasionWeakerStronger (TCP 443)

Reading a WireGuard config

[Interface]
PrivateKey = <your private key>
Address = 10.0.0.2/32
DNS = 10.0.0.1

[Peer]
PublicKey = <server public key>
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
  • [Interface] describes your end: your private key, the address you take on inside the tunnel, and the DNS server to use while connected.
  • [Peer] describes the server: its public key and Endpoint.
  • AllowedIPs is the one to understand. 0.0.0.0/0 routes all your traffic through the tunnel; a narrower range such as 10.0.0.0/24 tunnels only specific networks, which is split tunneling.
  • PersistentKeepalive sends a small packet every 25 seconds so a home router or mobile carrier does not drop the UDP mapping. You need it behind NAT; you can omit it when the client has a stable public address.

Reading an OpenVPN config

OpenVPN packs the same ideas into directives, and usually ships the keys and certificates inline or alongside:

client
dev tun
proto udp
remote vpn.example.com 1194
cipher AES-256-GCM
redirect-gateway def1   # route all traffic, the OpenVPN equivalent of 0.0.0.0/0
<ca>...</ca>
<cert>...</cert>
<key>...</key>

redirect-gateway def1 is the full-tunnel switch; drop it to split tunnel and add explicit route lines instead. Switching proto udp to proto tcp and remote ... 443 is the classic trick for networks that block everything except web traffic, at the cost of the TCP-over-TCP slowdown.

MTU, the quiet source of pain

Both protocols add header overhead, so the usable packet size inside the tunnel is smaller than outside it. When pages load but large transfers stall, a wrong MTU is the usual cause. WireGuard defaults to 1420 and lets you set MTU in the interface block; OpenVPN exposes tun-mtu and mssfix. If a connection is up but flaky, lowering the MTU is the first thing to try.

The key pair

Both protocols rest on a key pair per client. The private key stays on the device and never leaves it; only the public key (WireGuard) or a signed certificate (OpenVPN) is shared with the server. Treat a config file containing a private key like a password, because anyone holding it can connect as you.

The VPN Config Generator builds a valid client configuration for you, generating keys in your browser so the private key stays on your device. If your interest is the other side of VPNs, how networks detect them, see how VPN and proxy detection works.