OpenVPN

On this page 7

OpenVPN is an open-source virtual private network protocol and software suite that creates encrypted tunnels between hosts by using TLS for key exchange and a custom record format for data transport. In network security, it is one of the most widely deployed solutions for remote access and site-to-site connectivity, valued for running in user space on almost any operating system.

First released in 2001, OpenVPN predates WireGuard by more than a decade and differs from IPsec in that it does not depend on kernel-level protocol support. It can run over UDP or TCP on a single configurable port, which makes it easy to pass through firewalls and NAT devices that block other VPN protocols.

How OpenVPN builds an encrypted tunnel

OpenVPN separates its traffic into a control channel and a data channel that are multiplexed over the same transport connection. The control channel runs a full TLS handshake to authenticate both peers and negotiate session keys, while the data channel carries the encapsulated IP packets or Ethernet frames.

On each host, OpenVPN attaches to a virtual network interface. A TUN device carries routed IP packets at layer 3, and a TAP device carries full Ethernet frames at layer 2, which allows bridging. Packets written to the virtual interface are read by the OpenVPN process, encrypted, wrapped in UDP or TCP, and sent to the peer, which reverses the process.

Because the entire stack runs in user space, every packet crosses the boundary between kernel and process twice. This design gives portability and flexibility, but it is also the main reason OpenVPN is slower than kernel-based alternatives. The DCO kernel module (data channel offload), available in recent versions, moves data-channel encryption into the kernel to reduce this cost.

The table below lists the main building blocks of a typical deployment.

ComponentRoleTypical choice
Control channelAuthenticates peers and negotiates keysTLS 1.2 or TLS 1.3
Data channel cipherEncrypts tunneled trafficAES-256-GCM or ChaCha20-Poly1305
Virtual interfaceConnects the tunnel to the operating systemTUN for routing, TAP for bridging
TransportCarries encrypted packetsUDP port 1194 by default
tls-crypt keyWraps control packets with a shared keyHides and protects the handshake
Main components of an OpenVPN connection

Authentication and key management in OpenVPN

OpenVPN supports several authentication models, and the choice determines both security and administrative effort. The strongest common setup relies on a private certificate authority (PKI) that issues a certificate to every server and client, often combined with a username and password or one-time codes checked through a plugin or a RADIUS server.

Revocation is handled through a certificate revocation list (CRL) that the server checks on each connection. Many breaches of OpenVPN deployments stem not from the protocol but from poorly protected CA keys or stale client certificates that were never revoked after an employee left.

MethodSecurity levelAdministrative effortSuitable for
Static pre-shared keyLow, no forward secrecyMinimalLegacy tests only, removed in recent versions
Certificates onlyHighModerate, requires a PKISite-to-site links
Certificates plus credentialsVery highHigherEmployee remote access
Certificates plus MFAVery highHighestPrivileged or regulated access
Authentication options and their trade-offs

Adding tls-crypt or tls-auth places a shared key in front of the TLS handshake. The server silently drops unauthenticated packets, which reduces exposure to port scanning and denial-of-service attempts against the TLS stack.

OpenVPN compared with WireGuard and IPsec

OpenVPN, WireGuard and IPsec solve the same problem with very different philosophies. OpenVPN favors configurability and firewall traversal, WireGuard favors minimal code and speed, and IPsec favors standardization and native support in network equipment.

PropertyOpenVPNWireGuardIPsec with IKEv2
Code base sizeLarge, tens of thousands of linesAbout 4,000 lines in the kernelLarge, varies by vendor
Cryptographic agilityNegotiable ciphersFixed modern primitivesNegotiable suites
TransportUDP or TCP, any portUDP onlyUDP 500 and 4500, ESP
Typical throughputModerate, higher with DCOHighHigh with hardware offload
Firewall traversalExcellent over TCP 443GoodOften blocked or filtered
Native router supportCommon in open firmwareGrowingNearly universal
OpenVPN against other common VPN protocols

The ability to run over TCP port 443 lets OpenVPN blend with ordinary HTTPS traffic on restrictive networks. However, tunneling TCP inside TCP can cause TCP meltdown, where retransmissions at both layers amplify each other under packet loss, so UDP remains the recommended default.

Configuring OpenVPN for practical deployments

A sound OpenVPN configuration depends on a few decisions that matter more than any individual option. Administrators must choose between full tunneling, which routes all client traffic through the VPN, and split tunneling, which sends only traffic for internal networks through it.

  • Use AEAD ciphers such as AES-256-GCM and let peers negotiate them through the data-ciphers option.
  • Require TLS 1.2 or higher and enable tls-crypt or tls-crypt-v2 for per-client control keys.
  • Push routes and DNS servers explicitly so clients do not leak name queries outside the tunnel.
  • Run the daemon as an unprivileged user after startup to limit the impact of a compromise.
  • Keep the CA private key offline and maintain an up-to-date revocation list.

Commercial distributions such as OpenVPN Access Server and firewall platforms such as pfSense provide web interfaces on top of the same engine. They simplify client profile generation but do not remove the need to understand the underlying options.

Limitations and frequent mistakes

OpenVPN is mature and well audited, yet its flexibility creates room for misconfiguration. The most frequent problems in production fall into a few recognizable patterns.

SymptomLikely causeFix
Low throughput on fast linksSingle-threaded user-space processingEnable DCO or consider WireGuard
Stalls under packet lossTCP transport causing meltdownSwitch to UDP where permitted
Large packets droppedMTU mismatch inside the tunnelTune tun-mtu or mssfix
DNS leaks on clientsDNS servers not pushed or enforcedPush DNS and block outside DNS
Former staff still connectCertificates never revokedMaintain and enforce the CRL
Common OpenVPN problems, causes and fixes

The idea in brief

OpenVPN builds a private, locked tunnel through the public internet. Anything sent through that tunnel is scrambled, so people on the same café network or along the route cannot read it.

Both ends must prove who they are before the tunnel opens, usually with digital certificates that work like signed ID cards. Its main strength is that it works almost everywhere, even on networks that block other VPN types, although it is often slower than newer options.

A practical scenario

A regional engineering firm with 60 employees needed remote access to its file servers and licensing servers. Several staff traveled to client sites whose guest networks blocked everything except web traffic, which ruled out its existing IPsec setup for those users.

The administrator deployed OpenVPN on the firm’s firewall with a primary profile on UDP 1194 and a fallback profile on TCP 443. Each employee received a certificate from an offline CA plus multi-factor authentication through the firm’s RADIUS server, and split tunneling sent only the office subnets through the VPN.

Over the following quarter, traveling staff connected successfully from every client site, and when two contractors finished their projects, revoking their certificates removed their access within minutes.