Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
OpenVPN uses certificates: your own small CA signs one certificate for the server and one per user. A tls-crypt key hides the VPN from scanners. Clients get an IP from the VPN network and routes to the company networks.
| Item | Value |
|---|---|
| Packages | openvpn, easy-rsa (RHEL: EPEL) |
| Service | openvpn-server@server.service (config /etc/openvpn/server/server.conf) |
| PKI (CA files) | for example /etc/openvpn/easy-rsa/pki/ |
| Port | 1194/udp (or 443/tcp through strict firewalls) |
| VPN network in this guide | 10.9.0.0/24 |
| Logs | journalctl -u openvpn-server@server, status file |
Install on RHEL, Rocky, Alma and Fedora
Install on Ubuntu and Debian
apt-get update
apt-get install -y openvpn easy-rsaBuild the CA and certificates
Keep the CA on the VPN server only for small setups; better on a separate, offline machine.
mkdir -p /etc/openvpn/easy-rsa
cp -r /usr/share/easy-rsa/3/* /etc/openvpn/easy-rsa/
cd /etc/openvpn/easy-rsa
./easyrsa init-pki
./easyrsa build-ca
./easyrsa build-server-full server nopass
./easyrsa build-client-full alice nopass
./easyrsa gen-crl
openvpn --genkey secret /etc/openvpn/server/tc.key
cp pki/ca.crt pki/issued/server.crt pki/private/server.key pki/crl.pem /etc/openvpn/server/(On Ubuntu the Easy-RSA files are in /usr/share/easy-rsa/.) build-ca asks for a CA passphrase — keep it safe; you need it for every new user.
First configuration: the server
port 1194
proto udp
dev tun
topology subnet
server 10.9.0.0 255.255.255.0
ca ca.crt
cert server.crt
key server.key
dh none
tls-crypt tc.key
crl-verify crl.pem
tls-version-min 1.2
data-ciphers AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305
auth SHA256
push "route 10.0.0.0 255.255.0.0"
push "dhcp-option DNS 10.0.0.53"
keepalive 10 120
user nobody
group nobody
persist-key
persist-tun
status /run/openvpn-server/status.log 30
verb 3
explicit-exit-notify 1| Setting | Why |
|---|---|
dh none | Use elliptic-curve key exchange (no slow DH file needed). |
tls-crypt tc.key | Encrypts the TLS handshake; scanners get no answer without the key. |
crl-verify crl.pem | Revoked users are refused. |
tls-version-min 1.2, data-ciphers | Only modern crypto. |
push "route …" | Split tunnel: only the company network goes through the VPN. For full tunnel use push "redirect-gateway def1". |
user nobody / group nobody | Drop root rights after start (Ubuntu: group nogroup). |
Forwarding, firewall with NAT, start:
echo 'net.ipv4.ip_forward = 1' > /etc/sysctl.d/90-openvpn.conf
sysctl --system
firewall-cmd --permanent --add-service=openvpn
firewall-cmd --permanent --zone=internal --add-interface=tun0
firewall-cmd --permanent --zone=public --add-masquerade
firewall-cmd --reload
systemctl enable --now openvpn-server@server
journalctl -u openvpn-server@server -n 20
Initialization Sequence Completed(Ubuntu with UFW: ufw allow 1194/udp, route rules and a NAT block in /etc/ufw/before.rules, as in the WireGuard guide.)
The client profile
One .ovpn file with everything inside is easiest for users (import it in OpenVPN Connect or openvpn --config):
client
dev tun
proto udp
remote vpn.example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
tls-version-min 1.2
data-ciphers AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305
auth SHA256
verb 3
<ca>
(contents of ca.crt)
</ca>
<cert>
(contents of pki/issued/alice.crt)
</cert>
<key>
(contents of pki/private/alice.key)
</key>
<tls-crypt>
(contents of tc.key)
</tls-crypt>Send the file through a safe channel (it contains Alice's private key). Test on Linux: openvpn --config alice.ovpn.
Daily use: users, revocation and the real uses
New user, revoke a user, update the CRL:
cd /etc/openvpn/easy-rsa
./easyrsa build-client-full bob nopass
./easyrsa revoke alice
./easyrsa gen-crl
cp pki/crl.pem /etc/openvpn/server/crl.pem
chmod 644 /etc/openvpn/server/crl.pem
cat /run/openvpn-server/status.log
journalctl -u openvpn-server@server -fLet op
The CRL has an end date (default 180 days). When it expires, no one can connect. Run gen-crl and copy it again before that — put it in a monthly cron job.
Real uses at work:
- Remote access for staff to internal apps and servers.
- Through strict networks: run on
443/tcp. - Company setups with LDAP/RADIUS logins or MFA plugins on top of certificates.
Make it safe
Security checklist:
- CA private key with a passphrase, ideally on an offline machine.
- One certificate per user and device; revoke at once when someone leaves; CRL renewed in time.
tls-crypt, TLS 1.2+, AEAD ciphers only; drop root (user/group).- Push only the routes users need; firewall what VPN users can reach.
- Consider an extra factor (password + certificate, MFA plugin) for admin access.
- Keep OpenVPN and OpenSSL updated.
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
TLS Error: TLS key negotiation failed to occur within 60 seconds | UDP 1194 blocked, wrong server address, or different tls-crypt key. | Open the port (firewall + cloud); check remote; same tc.key. |
VERIFY ERROR … CRL has expired / nobody can connect | The CRL is too old. | ./easyrsa gen-crl, copy crl.pem, restart. |
certificate verify failed for one user | The user was revoked or the cert expired. | ./easyrsa show-cert NAME; make a new one. |
| Connected, but no access to servers | No forwarding/NAT, or the route is not pushed. | ip_forward, masquerade, push "route …". |
Cannot open TUN/TAP dev /dev/net/tun | No TUN device (containers, some VPS). | Load tun; enable TUN in the VPS panel or container settings. |
Options error: … unsupported on an old client | Client too old for the new settings. | Update the client (OpenVPN 2.5+ / Connect 3+). |
| Service fails on RHEL with a new port | SELinux port label. | semanage port -a -t openvpn_port_t -p udp 1195. |
Next steps
- Quick how-tos: Server for remote users.
- Command page: openvpn, Command page: openssl.
- At work: Classic TLS VPN. The faster option: WireGuard.
- The firewall around it: firewalld.
1Why must you renew the CRL regularly?
The CRL has an end date; when it expires, OpenVPN refuses every client.
2What does tls-crypt add?
It encrypts and authenticates the TLS handshake, so scanners without the key get no answer.