الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

openvpn

OpenVPN: the classic TLS-based VPN for remote access and site-to-site links, with certificates and many client apps.

المستوى
خدمة DevSecOps
المجموعة
خدمات الشبكة
يحتاج root
نعم
الحزمة
openvpn

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

OpenVPN builds a tunnel over UDP or TCP (default 1194/udp, or 443/tcp to pass strict firewalls). Authentication uses a PKI: a CA, a server certificate and one certificate per client (made with easy-rsa), optionally plus username/password or MFA. Configs are .conf (server) and .ovpn (client, can contain the certificates inline). It is older and slower than WireGuard, but very common in companies and works almost everywhere.

طريقة الكتابة

openvpn --config FILE
systemctl start openvpn-server@NAME | openvpn-client@NAME

الأجزاء الرئيسية

Server config keys

port / proto / dev
1194, udp|tcp, tun.
ca / cert / key / dh
PKI files.
tls-crypt FILE
Encrypt and protect the control channel.
server 10.8.0.0 255.255.255.0
VPN address pool.
push "route …"
Routes for clients.
data-ciphers AES-256-GCM:CHACHA20-POLY1305
Allowed ciphers.
user nobody / group nobody
Drop root after start.
crl-verify FILE
Revoked clients list.

الخيارات 4

الأكثر استخدامًا

Command flags

--config FILE
Use a config file.
--verb N
Log level (3 normal, 5+ debug).
--genkey tls-crypt FILE
Make a tls-crypt key.
--show-ciphers
List ciphers.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Install (EPEL) and make a PKI with easy-rsa

    dnf install -y epel-release && dnf install -y 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 vpn1 nopass
    ./easyrsa build-client-full laptop-hosam
  2. 2Make the tls-crypt key

    openvpn --genkey tls-crypt /etc/openvpn/server/tc.key
  3. 3A small server config

    cat /etc/openvpn/server/vpn.conf
    port 1194
    proto udp
    dev tun
    ca ca.crt
    cert vpn1.crt
    key vpn1.key
    dh none
    tls-crypt tc.key
    server 10.8.0.0 255.255.255.0
    push "route 192.168.122.0 255.255.255.0"
    data-ciphers AES-256-GCM:CHACHA20-POLY1305
    user nobody
    group nobody
    persist-key
    persist-tun
    crl-verify crl.pem
  4. 4Open the firewall and start

    firewall-cmd --permanent --add-service=openvpn --add-masquerade && firewall-cmd --reload
    systemctl enable --now openvpn-server@vpn
  5. 5Check connected clients

    cat /run/openvpn-server/status-vpn.log
    journalctl -u openvpn-server@vpn -n 30
  6. 6Client file (inline certs)

    head -8 laptop-hosam.ovpn
    client
    dev tun
    proto udp
    remote vpn.example.com 1194
    remote-cert-tls server
    <ca>
    -----BEGIN CERTIFICATE-----
  7. 7Connect from Linux

    openvpn --config laptop-hosam.ovpn
    nmcli connection import type openvpn file laptop-hosam.ovpn
  8. 8Remove a lost laptop (revoke)

    cd /etc/openvpn/easy-rsa && ./easyrsa revoke laptop-hosam && ./easyrsa gen-crl
    cp pki/crl.pem /etc/openvpn/server/crl.pem
    systemctl restart openvpn-server@vpn
  9. 9Check certificate expiry

    openssl x509 -in /etc/openvpn/server/vpn1.crt -noout -enddate
  10. 10Make a new client for a colleague

    cd /etc/openvpn/easy-rsa && ./easyrsa build-client-full laptop-sara
    ls pki/issued/laptop-sara.crt pki/private/laptop-sara.key

انتبه

  • Keep the CA private key offline if you can; whoever has it can make valid clients.
  • Without crl-verify, revoked clients can still connect.
  • Do not use comp-lzo/compression (VORACLE attack) and old ciphers (BF-CBC).

الملفات

/etc/openvpn/server/
Server configs and keys.
/etc/openvpn/easy-rsa/pki/
The PKI (CA key!).

نصائح للحفظ

  • For new small setups WireGuard is simpler; OpenVPN is good when you need TCP/443 or existing clients.

رموز الخروج

0Success.
1Error.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man 8 openvpn