Why host OpenVPN Server on a VPS?
Shared commercial VPN solutions require trusting a third-party provider that can log, resell or expose your connection data. By hosting OpenVPN Server on your own VPS, you are the sole administrator: you choose the level of logging, the authorized users and the encryption protocols (TLS 1.3, AES-256-GCM). It is also the ideal solution to interconnect distributed teams, secure access to your internal services or bypass the network restrictions of a corporate environment, all at a controlled cost.
What you can do with OpenVPN Server
- Secure the connections of your remote-working staff with an encrypted tunnel to your internal network
- Expose your internal services (databases, back office, monitoring tools) only via VPN, without opening them to the Internet
- Interconnect several sites or offices in a site-to-site virtual private network
- Protect your communications on public or untrusted Wi-Fi networks
- Finely manage access rights per user thanks to the OpenVPN certificate system
- Audit and log connections coming into your infrastructure from a centralized point under your control
Prerequisites: server and network
Before starting, check these points on your VPS.
Minimum resources: 1 vCPU and 512 MB of RAM are enough for personal use or up to 10 simultaneous users. Beyond 50 active connections, plan for 2 vCPU and 1 GB of RAM to absorb encryption without bandwidth degradation.
Operating system: Ubuntu 22.04 LTS or Debian 12 (both supported by the official OpenVPN repository). AlmaLinux 9 and Rocky Linux 9 also work with EPEL packages.
Network port: UDP 1194 (default) or TCP 443 to pass through restrictive firewalls. On your ServOrbit VPS, open this port in the security rules before starting the installation. A single port is enough.
Root access: required to create virtual network interfaces (tun0), modify iptables rules and enable IP forwarding.
IP forwarding: enable it before continuing:
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl -pInstall OpenVPN and Easy-RSA (community route)
Update the system and install packages
apt update && apt upgrade -y apt install -y openvpn easy-rsaThis approach has no client limit and requires no commercial license. Easy-RSA manages your local certificate authority (CA).
Generate the server certificate and Diffie-Hellman parameters
./easyrsa gen-req server nopass ./easyrsa sign-req server server openssl dhparam -out /etc/openvpn/dh.pem 2048 openvpn --genkey secret /etc/openvpn/ta.keyThe
ta.keykey (TLS Auth) protects against DoS attacks on the UDP port before the TLS handshake even begins.Generate a client certificate
./easyrsa gen-req client1 nopass ./easyrsa sign-req client client1Repeat this operation for each user. The pair
client1.crt+client1.key+ca.crt+ta.keymakes up the.ovpnprofile to distribute.Copy the necessary files to /etc/openvpn
cp pki/ca.crt pki/issued/server.crt pki/private/server.key /etc/openvpn/Keep the
pki/private/files with600permissions: they should only be readable by root.
Configure server.conf
Create /etc/openvpn/server.conf with the following content. Each directive is commented.
port 1194
proto udp
dev tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh.pem
tls-auth /etc/openvpn/ta.key 0
key-direction 0
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
# Push default route (full tunnel)
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 9.9.9.9"
push "dhcp-option DNS 149.112.112.112"
keepalive 10 120
cipher AES-256-GCM
tls-version-min 1.2
user nobody
group nogroup
persist-key
persist-tun
status /var/log/openvpn/openvpn-status.log
log-append /var/log/openvpn/openvpn.log
verb 3Enable and start the service:
mkdir -p /var/log/openvpn
systemctl enable --now openvpn@server
systemctl status openvpn@serverFull tunnel or split tunneling: choosing the right mode
Full tunnel (redirect-gateway def1): all client traffic goes through the VPN. Useful for protecting users on untrusted networks or for unifying Internet exits. Downside: the VPS bandwidth becomes the bottleneck for all flows.
Split tunneling: only traffic destined for your private network (e.g. 10.8.0.0/24) goes through the VPN. The rest exits directly from the client. To enable it, replace the redirect-gateway line with specific routes in server.conf:
push "route 192.168.1.0 255.255.255.0"This reduces load on the server and improves overall performance, but connections outside the VPN are no longer protected.
Create and distribute a .ovpn client profile
A standalone .ovpn file embeds all certificates. Generate it as follows:
cat > /tmp/client1.ovpn << EOF
client
dev tun
proto udp
remote <YOUR-VPS-IP> 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-GCM
verb 3
key-direction 1
<ca>
$(cat /etc/openvpn/easy-rsa/pki/ca.crt)
</ca>
<cert>
$(cat /etc/openvpn/easy-rsa/pki/issued/client1.crt)
</cert>
<key>
$(cat /etc/openvpn/easy-rsa/pki/private/client1.key)
</key>
<tls-auth>
$(cat /etc/openvpn/ta.key)
</tls-auth>
EOFTransfer this file to the client via a secure channel (SCP or a single-use link). Then simply import it into OpenVPN Connect (Windows, macOS, Android, iOS) or NetworkManager (Linux) to establish the connection.
Security: fail2ban, ufw and disabling IPv6
ufw firewall — open only what is necessary:
ufw allow ssh
ufw allow 1194/udp
ufw enableIf you use TCP 443 instead of UDP 1194, adapt the rule.
fail2ban for the OpenVPN port:
Create /etc/fail2ban/jail.d/openvpn.conf:
[openvpn]
enabled = true
port = 1194
protocol = udp
filter = openvpn
logpath = /var/log/openvpn/openvpn.log
maxretry = 5
bantime = 3600Then create the filter /etc/fail2ban/filter.d/openvpn.conf:
[Definition]
failregex = .*TLS Error: TLS key negotiation failed.*<HOST>.*
.*VERIFY ERROR:.*<HOST>.*Activate:
systemctl restart fail2ban
fail2ban-client status openvpnDisable IPv6 if not needed: an unprotected IPv6 interface can bypass your tunnel. If your infrastructure does not need IPv6:
echo 'net.ipv6.conf.all.disable_ipv6=1' >> /etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6=1' >> /etc/sysctl.conf
sysctl -pPerformance: MTU and cipher choice
MTU and fragmentation: OpenVPN encryption adds headers. By default the tunnel MTU (tun-mtu) is 1500, but UDP encapsulation can cause fragmentation on some networks. To avoid this, add to server.conf:
tun-mtu 1400
mssfix 1360If you observe slow transfers or drops on connections with a low MTU (mobile networks, some corporate VPNs), reduce tun-mtu to 1300.
Cipher choice: AES-256-GCM is recommended for modern Linux kernels, which benefit from AES-NI hardware instructions (check with grep -m1 'aes' /proc/cpuinfo). For highly CPU-constrained servers, AES-128-GCM halves the encryption cost without significant security reduction for common use cases.
UDP or TCP: UDP 1194 is the default and most performant mode. TCP 443 is useful to bypass restrictive corporate firewalls, but introduces the "TCP over TCP" problem (redundant retransmissions) which degrades performance under packet loss.
Troubleshooting: common errors
TLS Error: TLS key negotiation failed
This error appears when the client cannot reach the server on the configured port. Check that the port is open (ss -ulnp | grep 1194), that the firewall rule is active, and that the ta.key key is identical on the server side (key-direction 0) and the client side (key-direction 1).
Routes not applied after connection
If traffic does not pass through the tunnel despite an established connection, check that IP forwarding is active (cat /proc/sys/net/ipv4/ip_forward must return 1) and that a NAT rule is in place:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADEReplace eth0 with the main interface of your VPS (ip route get 8.8.8.8 to identify it).
Connections dropping regularly
If the tunnel disconnects every 2 minutes, check the keepalive in server.conf (keepalive 10 120: ping every 10 s, timeout at 120 s). On the client side, add ping-restart 60 to the .ovpn profile to force a clean reconnection before the server timeout.
VERIFY ERROR: depth=0, error=certificate is not yet valid
The server or client clock is out of sync. Synchronize NTP: timedatectl set-ntp true.
OpenVPN vs WireGuard: which to choose?
Scroll the table
| Criterion | OpenVPN | WireGuard |
|---|---|---|
| Protocol | TLS/SSL (OpenSSL) | ChaCha20-Poly1305 (modern cryptography) |
| Performance | Good, slightly slower | Very high, lower latency |
| Configuration | Detailed .conf files, learning curve | Simpler, public/private key pairs |
| Compatibility | All OS, restrictive firewalls (TCP 443) | Excellent on Linux, less universal |
| Certificate revocation | Built-in CRL, fine-grained per-user management | Remove public key only |
| Ideal use case | Teams, site-to-site, corporate environments | Personal access, mobility, performance |
A ServOrbit VPS as your private OpenVPN server
A ServOrbit VPS with root access, dedicated IPv4 and OS choice is the ideal platform for an OpenVPN server: you retain full control over certificates, logs and access rules. The OpenVPN Server template is available in the Marketplace for a quick start, or follow this guide for a complete manual installation via the community route. To get started: /vps-cloud.
The official documentation
For advanced configuration, tool-specific options and version changes, refer to the official OpenVPN Community documentation. This guide covers going live on a ServOrbit VPS; the vendor documentation remains the reference for fine-tuning.