Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
openvpn [23/08/2017 - 15:11] – [Zertifikate zurückziehen] thommie | openvpn [17/08/2024 - 07:06] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | https:// | ||
+ | |||
====== Server-Konfiguration ====== | ====== Server-Konfiguration ====== | ||
- | **–verify-x509-name name type** Accept connections | + | '' |
+ | |||
+ | ''### | ||
+ | |||
+ | '' | ||
+ | |||
+ | ''# | ||
+ | |||
+ | '' | ||
+ | |||
+ | ''# | ||
+ | |||
+ | ''# | ||
+ | |||
+ | ''# | ||
+ | |||
+ | '' | ||
+ | |||
+ | ''# | ||
+ | |||
+ | '' | ||
+ | |||
+ | ''# | ||
+ | ''# | ||
+ | |||
+ | '' | ||
+ | |||
+ | ''# | ||
+ | subnet '' | ||
+ | |||
+ | ''# | ||
+ | ifconfig-pool-persist ipp.txt '' | ||
+ | |||
+ | ''# | ||
+ | client-to-client '' | ||
+ | |||
+ | ''# | ||
+ | sndbuf 393216\\ | ||
+ | rcvbuf 393216 '' | ||
+ | |||
+ | ''## | ||
+ | cd / | ||
+ | |||
+ | ''## | ||
+ | ca / | ||
+ | ## cert of openvpn server\\ | ||
+ | cert / | ||
+ | ''## | ||
+ | key / | ||
+ | # diffie hellman parameter\\ | ||
+ | # create with: openssl genpkey -genparam -algorithm DH -out / | ||
+ | dh / | ||
+ | |||
+ | ''# | ||
+ | crl-verify / | ||
+ | |||
+ | ''# | ||
+ | # Details: [[https:// | ||
+ | # old method (Name/name-prefix from CN field)\\ | ||
+ | # verify-x509-name locutus.netzwissen.local name '' | ||
+ | |||
+ | ''# | ||
+ | remote-cert-eku "TLS Web Client Authentication" | ||
+ | |||
+ | ''# | ||
+ | cipher AES-256-CBC\\ | ||
+ | # HMAC Authentication\\ | ||
+ | auth SHA256 '' | ||
+ | |||
+ | ''# | ||
+ | comp-lzo '' | ||
+ | |||
+ | ''# | ||
+ | # tls-version-min 1.2 '' | ||
+ | |||
+ | ''## | ||
+ | ## redirect | ||
+ | ## push " | ||
+ | push " | ||
+ | push " | ||
+ | push " | ||
+ | |||
+ | ''# | ||
+ | push " | ||
+ | push " | ||
+ | |||
+ | ''# | ||
+ | # duplicate-cn # permissions after connect\\ | ||
+ | user nobody\\ | ||
+ | group nogroup '' | ||
+ | |||
+ | ''# | ||
+ | persist-key '' | ||
+ | |||
+ | ''# | ||
+ | persist-tun '' | ||
+ | |||
+ | ''### | ||
+ | log / | ||
+ | |||
+ | ''# | ||
+ | status / | ||
+ | \\ | ||
+ | # dont repeat messages so often\\ | ||
+ | mute 20 '' | ||
- | Which X.509 name is compared to **name** depends on the setting of type. **type** can be " | + | ''# |
+ | verb 6 '' | ||
- | **–verify-x509-name | + | '' |
+ | daemon '' | ||
- | **–verify-x509-name** is a useful replacement for the **–tls-verify** option to verify the remote host, because **–verify-x509-name** works in a **–chroot** environment without any dependencies. | + | ''# |
+ | management localhost 7505 '' | ||
- | Using a name prefix is a useful alternative to managing a CRL (Certificate Revocation List) on the client, since it allows the client to refuse all certificates except for those associated with designated servers. | ||
- | **NOTE:** Test against a name prefix only when you are using OpenVPN with a custom CA certificate that is under your control. Never use this option with type " | ||
====== Management Console ====== | ====== Management Console ====== | ||
Die Management Konsole läuft auf localhost und ist über P. 7505 erreichbar. | Die Management Konsole läuft auf localhost und ist über P. 7505 erreichbar. | ||
- | <code > | + | '' |
- | root@server6:/ | + | |
- | </ | + | |
Beenden mit quit. | Beenden mit quit. | ||
- | <code > | + | '' |
- | INFO: | + | |
- | help | + | |
- | Management Interface for OpenVPN 2.3.10 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Feb 2 2016 | + | |
- | Commands: | + | |
- | auth-retry t | + | |
- | bytecount n : Show bytes in/out, update every n secs (0=off). | + | |
- | echo [on|off] [N|all] | + | |
- | exit|quit | + | |
- | forget-passwords | + | |
- | help | + | |
- | hold [on|off|release] | + | |
- | release current hold and start tunnel. | + | |
- | kill cn : Kill the client instance(s) having common name cn. | + | |
- | kill IP: | + | |
- | load-stats | + | |
- | log [on|off] [N|all] | + | |
- | + show last N lines or ' | + | |
- | mute [n] | + | |
- | needok type action | + | |
- | where action = ' | + | |
- | needstr type action | + | |
- | where action is reply string. | + | |
- | net : (Windows only) Show network info and routing table. | + | |
- | password type p : Enter password p for a queried OpenVPN password. | + | |
- | remote type [host port] : Override remote directive, type=ACCEPT|MOD|SKIP. | + | |
- | proxy type [host port flags] : Enter dynamic proxy server info. | + | |
- | pid : Show process ID of the current OpenVPN process. | + | |
- | pkcs11-id-count | + | |
- | pkcs11-id-get index : Get PKCS#11 identity at index. | + | |
- | client-auth CID KID : Authenticate client-id/ | + | |
- | client-auth-nt CID KID : Authenticate client-id/ | + | |
- | client-deny CID KID R [CR] : Deny auth client-id/ | + | |
- | text R and optional client reason text CR | + | |
- | client-kill CID [M] : Kill client instance CID with message M (def=RESTART) | + | |
- | env-filter [level] | + | |
- | client-pf CID : Define packet filter for client CID (MULTILINE) | + | |
- | rsa-sig | + | |
- | Enter signature base64 on subsequent lines followed by END | + | |
- | signal s | + | |
- | s = SIGHUP|SIGTERM|SIGUSR1|SIGUSR2. | + | |
- | state [on|off] [N|all] : Like log, but show state history. | + | |
- | status [n] | + | |
- | test n | + | |
- | username type u : Enter username u for a queried OpenVPN username. | + | |
- | verb [n] | + | |
- | version | + | |
- | </ | + | |
====== Debugging auf OpenVPN Client Seite (Linux) ====== | ====== Debugging auf OpenVPN Client Seite (Linux) ====== | ||
- | <code > | + | '' |
- | journalctl -fu NetworkManager | + | |
- | </ | + | |
====== Client IPs fest zuweisen ====== | ====== Client IPs fest zuweisen ====== | ||
In die *.conf kommt eine neue Direktive: | In die *.conf kommt eine neue Direktive: | ||
- | <code > | + | '' |
- | client-config-dir / | + | |
- | </ | + | |
In diesem Verzeichnis für jeden Client einen Datei openvpn_dvsdnet_[name] legen. Diese enthält die IP Adresse und die Netzmaske des Clients: | In diesem Verzeichnis für jeden Client einen Datei openvpn_dvsdnet_[name] legen. Diese enthält die IP Adresse und die Netzmaske des Clients: | ||
- | <code > | + | '' |
- | ifconfig-push 192.168.50.16 255.255.255.0 | + | |
- | </ | + | |
OpenVPN liest diese Datei beim Connect zusätzlich ein, aber DNS und Gateway kommen weiterhin über die zentralen push Kommandos. Ggf kann man auch ein Client-spezifisches Push anhängen, siehe dazu [[http:// | OpenVPN liest diese Datei beim Connect zusätzlich ein, aber DNS und Gateway kommen weiterhin über die zentralen push Kommandos. Ggf kann man auch ein Client-spezifisches Push anhängen, siehe dazu [[http:// | ||
Zeile 97: | Zeile 147: | ||
====== EASYRSA: CA einrichten ====== | ====== EASYRSA: CA einrichten ====== | ||
- | <code > | + | '' |
- | ./easyrsa init-pki | + | |
- | ./easyrsa build-ca | + | |
- | </ | + | |
DH erzeugen | DH erzeugen | ||
- | <code > | + | '' |
- | ./easyrsa gen-dh | + | ====== |
- | </ | + | |
- | + | ||
- | ====== Zertifikate erzeugen ====== | + | |
Signing Request (CSR) erzeugen, mit **nopass** = Key **ohne** Passwort | Signing Request (CSR) erzeugen, mit **nopass** = Key **ohne** Passwort | ||
- | <code > | ||
- | ./easyrsa gen-req EntityName | ||
- | ./easyrsa gen-req EntityName | + | '' |
- | </code> | + | |
danach signieren mit | danach signieren mit | ||
- | <code > | + | '' |
- | ./easyrsa sign-req server EntityName | + | |
- | + | ||
- | ./easyrsa sign-req client EntityName | + | |
- | </ | + | |
//server// und //client// bestimmt, ob es ein Server oder Client Zertifikat ist. | //server// und //client// bestimmt, ob es ein Server oder Client Zertifikat ist. | ||
- | ===== Achtung bei OpenVPN ===== | ||
- | Der Client sollte den im OpenVPN Zertifikat angegebenen Common Name prüfen. Server prüft seinerseits den Zertifikatstyp des Clients (RFC3280): | + | **Achtung bei OpenVPN**: der Client sollte den im OpenVPN Zertifikat angegebenen Common Name prüfen. Server prüft seinerseits den Zertifikatstyp des Clients (RFC3280): |
- | <code > | + | '' |
- | # Verification of certs | + | ====== EASYRSA: Zertifikate zurückziehen ====== |
- | # Details: https:// | + | |
- | # old method (Name/ | + | |
- | # verify-x509-name locutus.netzwissen.local name | + | |
- | # new method from RFC3280: type of certificate must be client | + | |
- | remote-cert-eku "TLS Web Client Authentication" | + | |
- | </ | + | |
- | ====== Zertifikate zurückziehen ====== | + | '' |
- | + | ||
- | <code > | + | |
- | ./easyrsa revoke server EntityName | + | |
- | </ | + | |
Danach mit easyrsa gen-crl die zurückgezogenen zertifikate in die crl aufnehmen. | Danach mit easyrsa gen-crl die zurückgezogenen zertifikate in die crl aufnehmen. | ||
Zeile 150: | Zeile 176: | ||
===== ===== | ===== ===== | ||
- | |||
====== Inhalte kontrollieren ====== | ====== Inhalte kontrollieren ====== | ||
+ | |||
+ | **Zertifikat** | ||
+ | |||
+ | '' | ||
**CSR** | **CSR** | ||
- | <code > | ||
- | openssl req -in www2.netzwissen.de.csr -text -noout | ||
- | </ | ||
- | **Zertifikat** | + | '' |
- | <code > | + | |
- | openssl | + | |
- | </ | + | |