it:intern:archiv:openvpn_server
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| it:intern:archiv:openvpn_server [2022/11/28 19:57] – ↷ Seite von it:intern:openvpn_server nach it:intern:archiv:openvpn_server verschoben bosses_admin | it:intern:archiv:openvpn_server [2023/05/19 08:02] (current) – gelöscht bosses_admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== OpenVPN Server Administration ====== | ||
| - | ===== Installation - manuell ===== | ||
| - | |||
| - | ==== Basisinstallation ==== | ||
| - | |||
| - | Ausgangssituation: | ||
| - | |||
| - | Notwendige Pakete installieren: | ||
| - | <code bash> | ||
| - | sudo apt update | ||
| - | sudo apt install openvpn | ||
| - | # Schon vorhanden: iptables openssl ca-certificates | ||
| - | </ | ||
| - | |||
| - | IPv4 Forwarding aktivieren | ||
| - | <code bash> | ||
| - | echo " | ||
| - | </ | ||
| - | in ''/ | ||
| - | <code bash> | ||
| - | net.ipv4.ip_forward = 1 | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== Anlegen eines VPN Bereiches ==== | ||
| - | |||
| - | folgt generell: [[https:// | ||
| - | |||
| - | Für jeden Bereich ein gesondertes easy-rsa Verzeichnis: | ||
| - | |||
| - | <code bash> | ||
| - | cd / | ||
| - | make-cadir easyrsa_BEREICH/ | ||
| - | |||
| - | vim / | ||
| - | |||
| - | cd easyrsa_BEREICH | ||
| - | ./easyrsa init-pki | ||
| - | |||
| - | ./easyrsa build-ca / hier ca-key-pass vergeben | ||
| - | |||
| - | ./easyrsa build-server-full server_BEREICH ## erst server-key-pass vergeben, dann ca-key-pass eingeben für Signierung | ||
| - | |||
| - | ./easyrsa gen-dh | ||
| - | |||
| - | echo " | ||
| - | chmod go-rwx pki/ | ||
| - | |||
| - | touch / | ||
| - | |||
| - | </ | ||
| - | |||
| - | Jetzt in ''/ | ||
| - | <code bash> | ||
| - | local 10.4.110.18 # Lokale listen-IP des Servers | ||
| - | port 1194 # unique port pro Bereich wählen! | ||
| - | proto udp | ||
| - | dev tun # muss pro Bereich durchnummeriert werden? | ||
| - | |||
| - | ca / | ||
| - | cert / | ||
| - | key / | ||
| - | dh / | ||
| - | |||
| - | auth SHA512 | ||
| - | cipher AES-256-CBC | ||
| - | |||
| - | server 10.8.1.0 255.255.255.0 # für clients zu vergebender IP-Bereich | ||
| - | topology subnet | ||
| - | |||
| - | push "route 10.4.0.0 255.255.0.0" | ||
| - | push " | ||
| - | push " | ||
| - | |||
| - | ifconfig-pool-persist ipp_BEREICH.txt # | ||
| - | |||
| - | keepalive 10 120 | ||
| - | |||
| - | persist-key | ||
| - | persist-tun | ||
| - | |||
| - | user nobody | ||
| - | group nogroup | ||
| - | |||
| - | status log/ | ||
| - | |||
| - | verb 3 | ||
| - | |||
| - | explicit-exit-notify | ||
| - | |||
| - | askpass / | ||
| - | |||
| - | </ | ||
| - | |||
| - | |||
| - | Server starten und registrieren mit: | ||
| - | <code bash> | ||
| - | systemctl start openvpn-server@server_BEREICH | ||
| - | systemctl enable openvpn-server@server_BEREICH | ||
| - | </ | ||
| - | |||
| - | CoreFirewall: | ||
| - | IP -> Firewall -> NAT | ||
| - | * Add dst-nat: | ||
| - | * DST-Address 46.189.75.134 | ||
| - | * Protocol udp | ||
| - | * DST-port < | ||
| - | * in Interface ether3 | ||
| - | * Action dest-nat | ||
| - | * Log_Prefix ovpn_ | ||
| - | * ToAddresses: | ||
| - | |||
| - | IP -> Routes | ||
| - | * add Route: | ||
| - | * 10.8.x.0/24 | ||
| - | * gateway <VPN Server IP> | ||
| - | |||
| - | IP -> Firewall -> Filter Rules | ||
| - | * Chain dst_Server, add Rule: | ||
| - | * Dst.Address: | ||
| - | * Protocol: udp | ||
| - | * Dst. Port: <Server PORT> | ||
| - | * Action: accept | ||
| - | |||
| - | IP -> Firewall -> Address Lists: | ||
| - | * Add AddressList | ||
| - | * Name: range_VPN< | ||
| - | * Address: 10.8.x.0/24 | ||
| - | |||
| - | Dann für internes Routing, Weiterleitungs-Regeln entsprechend | ||
| - | |||
| - | https:// | ||
| - | |||
| - | |||
| - | |||
| - | ==== MFA einrichten ==== | ||
| - | |||
| - | <code bash | oath_material.sh> | ||
| - | #!/bin/sh | ||
| - | # | ||
| - | # Sample script to verify MFA using oath-tool | ||
| - | |||
| - | passfile=$1 | ||
| - | |||
| - | # Get the user/pass from the tmp file | ||
| - | user=$(head -1 $passfile) | ||
| - | pass=$(tail -1 $passfile) | ||
| - | |||
| - | |||
| - | # Find the entry in our oath.secrets file, ignore case | ||
| - | # | ||
| - | secretline=$(grep -i -m 1 " | ||
| - | secret=$(echo " | ||
| - | |||
| - | # Calculate the code we should expect | ||
| - | # | ||
| - | code=`oathtool --totp $secret` | ||
| - | |||
| - | if [ " | ||
| - | then | ||
| - | exit 0 | ||
| - | fi | ||
| - | |||
| - | # See if we have password and MFA, or just MFA | ||
| - | |||
| - | echo " | ||
| - | |||
| - | if [ $? -eq 0 ]; | ||
| - | then | ||
| - | realpass=$(echo " | ||
| - | mfatoken=$(echo " | ||
| - | |||
| - | # put code here to verify $realpass, the code below the if validates $mfatoken or $pass if false | ||
| - | # exit 0 if the password is correct, the exit below will deny access otherwise | ||
| - | fi | ||
| - | |||
| - | # If we make it here, auth hasn't succeeded, don't grant access | ||
| - | exit 1 | ||
| - | </ | ||
| - | |||
| - | '' | ||
| - | <code bash> | ||
| - | -rwxr----- 1 root nogroup | ||
| - | -rwxr-x--- 1 root nogroup | ||
| - | </ | ||
| - | |||
| - | in server.conf einfügen: | ||
| - | < | ||
| - | script-security 2 | ||
| - | auth-user-pass-verify / | ||
| - | </ | ||
| - | |||
| - | in client.conf einfügen: | ||
| - | < | ||
| - | auth-user-pass | ||
| - | </ | ||
| - | |||
| - | ==== User hinzufügen ==== | ||
| - | |||
| - | <code bash> | ||
| - | cd / | ||
| - | ./easyrsa build-client-full CLIENTNAME | ||
| - | ./easyrsa build-client-full CLIENTNAME nopass | ||
| - | </ | ||
| - | |||
| - | für Erstellung ovpn config benötigt: | ||
| - | * pki/ca.crt | ||
| - | * pki/ | ||
| - | * pki/ | ||
| - | |||
| - | <code | clientname.ovpn> | ||
| - | client | ||
| - | dev tun | ||
| - | proto udp | ||
| - | remote 46.189.75.134 1195 | ||
| - | resolv-retry infinite | ||
| - | nobind | ||
| - | persist-key | ||
| - | persist-tun | ||
| - | auth SHA512 | ||
| - | cipher AES-256-CBC | ||
| - | verb 3 | ||
| - | remote-cert-tls server | ||
| - | auth-user-pass | ||
| - | auth-nocache | ||
| - | <ca> | ||
| - | [...] | ||
| - | </ca> | ||
| - | < | ||
| - | [...] | ||
| - | </ | ||
| - | <key> | ||
| - | [...] | ||
| - | </ | ||
| - | |||
| - | </ | ||
| - | |||
| - | verschlüsseltes zip erstellen: | ||
| - | <code bash> | ||
| - | zip -e clientname.zip clientname/ | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | Eventuell noch MFA Code und Secret erstellen mit Script: | ||
| - | |||
| - | <code bash> | ||
| - | ./ | ||
| - | </ | ||
| - | |||
| - | Dann Secret in / | ||
| - | ==== Weitere Info ==== | ||
| - | |||
| - | [[https:// | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Installation - Skript (alt) ===== | ||
| - | |||
| - | Installscripte sind auf GitHub geforkt: \\ | ||
| - | [[https:// | ||
| - | |||
| - | Zum installieren: | ||
| - | |||
| - | 1.: Ordner ''/ | ||
| - | |||
| - | <code bash update_script.sh> | ||
| - | #!/bin/bash | ||
| - | cd / | ||
| - | rm openvpn-install.sh | ||
| - | wget https:// | ||
| - | chmod 0700 openvpn-install.sh | ||
| - | </ | ||
| - | |||
| - | Dann '' | ||
| - | |||
| - | Es sollte der interne DNS Resolver verwendet werden (oder hardkodiert IP des lokalen DNS) | ||
| - | |||
| - | CA/Server Zertifikate und erster Nutzer werden automatisch angelegt. | ||
| - | :!: Dieser User hat kein Passwort :!: | ||
| - | |||
| - | Ergebnis sollte so ähnlich aussehen: | ||
| - | |||
| - | '' | ||
| - | '' | ||
| - | '' | ||
| - | |||
| - | //Note: Auf Raspi wird nicht / | ||
| - | |||
| - | |||
| - | ===== Konfiguration (alt) ===== | ||
| - | |||
| - | Server wird vorkonfiguriert installiert | ||
| - | |||
| - | Config liegt in: ''/ | ||
| - | |||
| - | Standardport: | ||
| - | |||
| - | ===== Userverwaltung (alt) ===== | ||
| - | |||
| - | Um neue User anzulegen, und bestehende User zu löschen: \\ | ||
| - | '' | ||
| - | --> Textbasierte Menüführung | ||
| - | |||
| - | |||
| - | |||
| - | ===== Netzwerkeinstellungen ===== | ||
| - | |||
| - | ==== Firewall & NAT Forwarding ==== | ||
| - | |||
| - | Port 1194 (UDP) weiterleiten auf OpenVPN Server IP | ||
| - | |||
| - | NAT Traversal: TODO | ||
| - | |||
| - | Lokale IP konfig: TODO | ||
| - | |||
| - | |||
| - | |||
| - | ===== Bestehende VPN Zugänge ===== | ||
| - | |||
| - | * Wasenwache (via REN - 10.4.110.23) | ||
| - | * Ulmer Straße (via PI - im Aufbau) | ||
| - | |||
| - | |||
| - | ===== Server-Admin ===== | ||
| - | |||
| - | ==== WaWa-Admin ==== | ||
| - | |||
| - | start/ | ||
| - | <code bash> | ||
| - | sudo systemctl < | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | ===== Server-Config ===== | ||
| - | |||
| - | ==== WaWa-Admin (alt) ==== | ||
| - | |||
| - | |||
| - | On VM REN | ||
| - | |||
| - | <file | server.conf> | ||
| - | local 10.4.110.23 | ||
| - | port 1194 | ||
| - | proto udp | ||
| - | dev tun | ||
| - | ca ca.crt | ||
| - | cert server.crt | ||
| - | key server.key | ||
| - | dh dh.pem | ||
| - | auth SHA512 | ||
| - | tls-crypt tc.key | ||
| - | topology subnet | ||
| - | server 10.8.0.0 255.255.255.0 | ||
| - | # push " | ||
| - | push "route 10.4.0.0 255.255.0.0" | ||
| - | ifconfig-pool-persist ipp.txt | ||
| - | push " | ||
| - | push " | ||
| - | push " | ||
| - | keepalive 10 120 | ||
| - | cipher AES-256-CBC | ||
| - | user nobody | ||
| - | group nobody | ||
| - | persist-key | ||
| - | persist-tun | ||
| - | status openvpn-status.log | ||
| - | verb 3 | ||
| - | crl-verify crl.pem | ||
| - | explicit-exit-notify | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== WaWa-Material ==== | ||
| - | |||
| - | On VM ... | ||
| - | |||
| - | <file | server.conf> | ||
| - | |||
| - | </ | ||
| - | |||
| - | |||
| - | ===== Client-Config ===== | ||
| - | |||
| - | ==== WaWa-Admin (alt) ==== | ||
| - | |||
| - | === Beispiel .ovpn File === | ||
| - | |||
| - | <file | user.ovpn> | ||
| - | client | ||
| - | dev tun | ||
| - | proto udp | ||
| - | remote 46.189.75.134 1194 | ||
| - | resolv-retry infinite | ||
| - | nobind | ||
| - | persist-key | ||
| - | persist-tun | ||
| - | remote-cert-tls server | ||
| - | auth SHA512 | ||
| - | cipher AES-256-CBC | ||
| - | ignore-unknown-option block-outside-dns | ||
| - | block-outside-dns | ||
| - | verb 3 | ||
| - | <ca> | ||
| - | -----BEGIN CERTIFICATE----- | ||
| - | [...] | ||
| - | -----END CERTIFICATE----- | ||
| - | </ca> | ||
| - | < | ||
| - | -----BEGIN CERTIFICATE----- | ||
| - | [...] | ||
| - | -----END CERTIFICATE----- | ||
| - | </ | ||
| - | <key> | ||
| - | -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
| - | [...] | ||
| - | -----END ENCRYPTED PRIVATE KEY----- | ||
| - | </ | ||
| - | < | ||
| - | -----BEGIN OpenVPN Static key V1----- | ||
| - | [...] | ||
| - | -----END OpenVPN Static key V1----- | ||
| - | </ | ||
| - | |||
| - | </ | ||
| - | |||
| - | === openVPN-GUI === | ||
| - | |||
| - | === UbuntuNetwork Manager === | ||
| - | |||
| - | Anlegen mittels New connection -> VPN (openvpn) | ||
| - | |||
| - | Vorbereitung: | ||
| - | |||
| - | |||
| - | * General Configuration | ||
| - | * VPN (openvpn) | ||
| - | * Gateway: 46.189.75.134 | ||
| - | * Connection Type: Password with Certifcates (TLS) | ||
| - | * CA Certificate: | ||
| - | * User Certificate: | ||
| - | * Private Key: private.key | ||
| - | * Private Key Password: Ask for this password every time | ||
| - | * Username: < | ||
| - | * Password: Ask for this password every time | ||
| - | * Advanced | ||
| - | * General | ||
| - | * Use custom gateway port: 1194 | ||
| - | * Set virtual device type: TUN | ||
| - | * All other options are off | ||
| - | * Security | ||
| - | * Cipher: AES-256-CBC | ||
| - | * HMAC Authentication: | ||
| - | * TLS Settings | ||
| - | * Server certificate check: Don't verify certificate identification | ||
| - | * Mode: TLS-Crypt | ||
| - | * Keyfile: tls-crypt.key | ||
| - | * Proxy | ||
| - | * Proxy Type: not required | ||
| - | * IPv4: Keep standard | ||
| - | * IPv6: Keep standard | ||
| - | |||
| - | Bei Verbindung muss 2x das selbe User-Passwort eingegeben werden | ||
it/intern/archiv/openvpn_server.1669665435.txt.gz · Last modified: 2022/12/04 06:25 (external edit)
