Data Channel Offload (DCO)
DCO provides the most significant performance improvement by processing data packets directly in kernel space.Overview
OpenVPN 2.6+ supports data channel offloading where:- Data packets are processed in kernel space
- Userspace OpenVPN acts as control plane only
- Dramatically reduces CPU usage and improves throughput
- Available on Linux (6.16+), Windows (10 2004+), and FreeBSD (14+)
DCO offers the best performance improvement with minimal configuration changes. It is automatically enabled when supported and compatible.
Enabling DCO
Verify kernel support
Linux (kernel 6.16+):For older kernels, use ovpn-backports:Windows (10 2004+/Server 2022):
- DCO-Win driver included in OpenVPN 2.6+ installers
- No additional setup required
- ovpn(4) kernel module included
- Automatically available
Configure for DCO compatibility
DCO is automatically enabled if configuration is compatible. Required settings:
DCO limitations
By design limitations
By design limitations
- Layer 3 only: No TAP (Layer 2) support
- AEAD ciphers only: AES-128/192/256-GCM and CHACHA20-POLY1305
- No compression: Compression and compression framing not supported
- Topology: Server requires
topology subnet - Minimum version: Peers must be OpenVPN 2.4.0+ (for AEAD cipher support)
- Windows DCO: Client and P2P mode only (not server mode)
- Windows CHACHA20: Requires Windows 11
Feature replacements
Feature replacements
These features are better handled at OS level with DCO:
- Shaper: Use
tc(traffic control) instead of--shaper - Packet manipulation: Use
nftables/iptablesinstead - Client-to-client: Handled by kernel routing table
DCO routing behavior
DCO uses transparent kernel routing:Disabling DCO
If needed, disable DCO explicitly:Cipher and protocol optimization
Cipher selection
Choose ciphers for best performance:AEAD ciphers (recommended)
AEAD ciphers (recommended)
AEAD (Authenticated Encryption with Associated Data) ciphers provide best performance:Performance characteristics:
- AES-GCM: Best on CPUs with AES-NI hardware acceleration
- CHACHA20-POLY1305: Best on mobile/ARM devices without AES-NI
- AEAD ciphers are required for DCO
Cipher negotiation
Cipher negotiation
Enable automatic negotiation:Verify negotiated cipher in logs:
NCP (Negotiable Crypto Parameters) automatically selects the best cipher both peers support, offering best performance with least CPU usage.
Legacy ciphers (avoid)
Legacy ciphers (avoid)
Avoid non-AEAD ciphers for performance:
- CBC mode ciphers (AES-256-CBC, BF-CBC) are slower
- Require separate HMAC authentication overhead
- Not compatible with DCO
Protocol selection
UDP vs TCP
UDP vs TCP
UDP (recommended):Advantages:Use TCP when:
- Better performance and lower latency
- No TCP-over-TCP issues
- Handles packet loss better
- Lower overhead
- Firewall blocks UDP
- Network heavily drops UDP packets
- Need HTTP proxy support
TCP optimization (when required)
TCP optimization (when required)
If you must use TCP, optimize with:
Compression
Disable compression
Compression typically hurts performance on modern networks:Why disable compression?
Why disable compression?
- CPU overhead: Compression/decompression consumes CPU
- Modern data: Most internet traffic already compressed (HTTPS, video, etc.)
- DCO incompatible: Cannot use DCO with compression enabled
- Security: Compression can leak information in some scenarios
Migration strategy
Migration strategy
For existing deployments with compression:
-
Phase 1: Add to server config
This accepts both compressed and uncompressed clients.
- Phase 2: Update all clients to remove compression
-
Phase 3: Remove
compressdirective from server
Network tuning
MTU optimization
Understanding MTU
Understanding MTU
MTU (Maximum Transmission Unit) affects performance:
- Too large: Fragmentation and packet loss
- Too small: Excessive overhead
Finding optimal MTU
Finding optimal MTU
Test MTU size:Set MTU in configuration:
Fragment and MSS
Fragment and MSS
For UDP connections with large packets:
Socket buffer tuning
Increase socket buffers for high-throughput connections:Larger buffers help on high-latency or high-bandwidth networks. Start with 512KB and adjust based on testing.
Fast I/O
Minimize latency:System-level optimization
CPU affinity
Pin OpenVPN to specific CPU cores:IRQ balancing
Balance network interrupts across CPUs:Kernel parameters
Optimize networking stack:File descriptor limits
Increase limits for high client counts:Logging optimization
Reduce log verbosity
High verbosity severely impacts performance:Mute repeated messages
Multi-threading and parallelization
Multiple server instances
Run multiple OpenVPN processes for different clients:- Each process uses separate CPU core
- Better scalability
- Load distribution
Process priority
Increase OpenVPN priority:Monitoring performance
Measure throughput
Test VPN throughput:Check CPU usage
Network statistics
Hardware acceleration
AES-NI
Verify CPU has AES-NI instructions:Crypto offload
Use cryptodev for hardware acceleration:Performance checklist
For optimal performance, ensure:Enable DCO
- Kernel module loaded
- Compatible configuration (tun, AEAD ciphers, no compression)
- OpenVPN built with
--enable-dco