Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
openvpn [24/08/2017 - 09:24] – [Zertifikate erzeugen] thommie | openvpn [17/08/2024 - 07:06] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | https:// | ||
+ | |||
====== Server-Konfiguration ====== | ====== Server-Konfiguration ====== | ||
- | < | + | '' |
- | ############################################################################## | + | |
- | # sources for configuration: | + | |
- | # http:// | + | |
- | # http:// | + | |
- | ### BASICS | + | '' |
- | mode server | + | |
- | # bridged vpn with client IP range | + | |
- | server-bridge 192.168.72.1 255.255.255.0 192.168.72.61 192.168.72.100 | + | |
- | # Protocol/ | + | '' |
- | proto udp | + | |
- | port 1194 | + | |
- | ### Type of operation | + | '' |
- | # operation with PKI | + | |
- | tls-server | + | |
- | # instead for using a symmetric key | + | |
- | # secret / | + | |
- | # for vpn with shared key | + | |
- | # tls-auth xxx 1 | + | |
- | # Device type | + | '' |
- | dev tap0 | + | |
- | # receive connection request on this local adress only | + | '' |
- | # if not defined, use all interfaces | + | |
- | local 192.168.172.1 | + | |
- | # topology and network | + | '' |
- | topology subnet | + | |
- | # make IPs persistant | + | |
- | ifconfig-pool-persist ipp.txt | + | |
- | # clients can see each other | + | |
- | client-to-client | + | |
- | # see http:// | + | '' |
- | sndbuf 393216 | + | |
- | rcvbuf 393216 | + | |
- | ## PKI - certificates and keys, directory of cert/key | + | '' |
- | cd / | + | |
- | ## Root CA which signed openvpn server and client certs | + | |
- | ca /etc/ | + | |
- | ## cert of openvpn server | + | |
- | cert / | + | |
- | ## key of server | + | |
- | key / | + | |
- | # diffie hellman parameter | + | |
- | # create with: openssl genpkey -genparam -algorithm DH -out / | + | |
- | dh / | + | |
- | # certificate revocation list, should be copied from CA | + | |
- | crl-verify / | + | |
- | # Verification of certs | + | '' |
- | # 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" | + | |
- | # Cipher algorithm | + | '' |
- | cipher AES-256-CBC | + | |
- | # HMAC Authentication | + | |
- | auth SHA256 | + | |
- | # tunnel compression | + | '' |
- | comp-lzo | + | ''# |
- | # hardening. Beware: can exclude pre-2.3.3 clients | + | '' |
- | # tls-version-min | + | |
- | ## pushed configs for clients for routing & dns | + | '' |
- | ## redirect all traffic to VPN | + | subnet '' |
- | ## push " | + | |
- | push "route 192.168.72.0 255.255.255.0 172.168.72.1" | + | |
- | push " | + | |
- | push " | + | |
- | push " | + | |
- | # http:// | + | |
- | push " | + | |
- | push " | + | |
- | # will not work with --ifconfig-pool-persist | + | '' |
- | # duplicate-cn | + | ifconfig-pool-persist |
- | # permissions after connect | + | |
- | user nobody | + | |
- | group nogroup | + | |
- | # dont re-read keys after --ping-restart | + | |
- | persist-key | + | |
- | # dont restart tun after --ping-restart | + | |
- | persist-tun | + | |
- | ### LOGGING | + | '' |
- | log / | + | client-to-client '' |
- | # Status info | + | |
- | status / | + | |
- | # dont repeat messages so often | + | |
- | mute 20 | + | |
- | # Log-Levels: 0 no logging, 4 standard, 5 + 6 debugging, 9 max | + | |
- | verb 6 | + | |
- | # Daemon-Mode: write to syslog | + | '' |
- | daemon | + | sndbuf 393216\\ |
+ | rcvbuf 393216 '' | ||
- | # Management console | + | ''## |
- | management localhost 7505 | + | 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/ | ||
+ | # 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 all traffic to VPN\\ | ||
+ | ## 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 '' | ||
+ | |||
+ | ''# | ||
+ | verb 6 '' | ||
+ | |||
+ | ''# | ||
+ | daemon '' | ||
+ | |||
+ | '' | ||
+ | management localhost 7505 '' | ||
Zeile 116: | Zeile 123: | ||
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 197: | Zeile 147: | ||
====== EASYRSA: CA einrichten ====== | ====== EASYRSA: CA einrichten ====== | ||
- | <code > | + | '' |
- | ./easyrsa init-pki | + | |
- | ./easyrsa build-ca | + | |
- | </ | + | |
DH erzeugen | DH erzeugen | ||
- | <code > | + | '' |
- | ./easyrsa gen-dh | + | |
- | </ | + | |
====== EASYRSA: Zertifikate erzeugen ====== | ====== EASYRSA: 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 | ||
- | # 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" | ||
- | </ | ||
+ | '' | ||
+ | ====== EASYRSA: Zertifikate zurückziehen ====== | ||
- | ====== 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 249: | Zeile 176: | ||
===== ===== | ===== ===== | ||
- | |||
====== Inhalte kontrollieren ====== | ====== Inhalte kontrollieren ====== | ||
+ | |||
+ | **Zertifikat** | ||
+ | |||
+ | '' | ||
**CSR** | **CSR** | ||
- | <code > | ||
- | openssl req -in www2.netzwissen.de.csr -text -noout | ||
- | </ | ||
- | **Zertifikat** | + | '' |
- | <code > | + | |
- | openssl | + | |
- | </ | + | |