Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 43OpenVPN · Network

Install and set up an OpenVPN server

OpenVPN is the classic TLS VPN. It is older and slower than WireGuard, but very common in companies: it works over TCP or UDP, through strict firewalls, with certificates, revocation lists and username/password or MFA plugins. This guide installs OpenVPN with Easy-RSA on RHEL and Ubuntu, builds the certificate authority, writes a modern server config, makes a single-file client profile, and shows how to revoke a user.

  • 11 Lessen
  • 14 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

43.1

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.

ItemValue
Packagesopenvpn, easy-rsa (RHEL: EPEL)
Serviceopenvpn-server@server.service (config /etc/openvpn/server/server.conf)
PKI (CA files)for example /etc/openvpn/easy-rsa/pki/
Port1194/udp (or 443/tcp through strict firewalls)
VPN network in this guide10.9.0.0/24
Logsjournalctl -u openvpn-server@server, status file

43.2

Install on RHEL, Rocky, Alma and Fedora

dnf -y install epel-release
dnf -y install openvpn easy-rsa

Commando's in deze les

43.3

Install on Ubuntu and Debian

apt-get update
apt-get install -y openvpn easy-rsa

43.4

Build 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.

43.5

First configuration: the server

/etc/openvpn/server/server.conf
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
SettingWhy
dh noneUse elliptic-curve key exchange (no slow DH file needed).
tls-crypt tc.keyEncrypts the TLS handshake; scanners get no answer without the key.
crl-verify crl.pemRevoked users are refused.
tls-version-min 1.2, data-ciphersOnly 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 nobodyDrop 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.)

43.6

The client profile

One .ovpn file with everything inside is easiest for users (import it in OpenVPN Connect or openvpn --config):

alice.ovpn
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.

43.7

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 -f

Let 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.

43.8

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.

43.9

Update and remove

dnf -y upgrade openvpn
apt-get install --only-upgrade -y openvpn
systemctl restart openvpn-server@server
systemctl disable --now openvpn-server@server
dnf -y remove openvpn easy-rsa

43.10

Fix common problems

ProblemCauseFix
TLS Error: TLS key negotiation failed to occur within 60 secondsUDP 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 connectThe CRL is too old../easyrsa gen-crl, copy crl.pem, restart.
certificate verify failed for one userThe user was revoked or the cert expired../easyrsa show-cert NAME; make a new one.
Connected, but no access to serversNo forwarding/NAT, or the route is not pushed.ip_forward, masquerade, push "route …".
Cannot open TUN/TAP dev /dev/net/tunNo TUN device (containers, some VPS).Load tun; enable TUN in the VPS panel or container settings.
Options error: … unsupported on an old clientClient too old for the new settings.Update the client (OpenVPN 2.5+ / Connect 3+).
Service fails on RHEL with a new portSELinux port label.semanage port -a -t openvpn_port_t -p udp 1195.

43.11

Next steps

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.

Alle commando's in dit hoofdstuk