OpenVPN und Freetz, wie stricke ich mein eigenes VPN: Unterschied zwischen den Versionen

Aus Zebradem WIKI
Zur Navigation springenZur Suche springen
Keine Bearbeitungszusammenfassung
SteveO (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Zeile 34: Zeile 34:
Mit WinSCP wechseln nach  
Mit WinSCP wechseln nach  
  /usr/share/doc/openvpn/examples
  /usr/share/doc/openvpn/examples
Ordner "easy-rsa" kopieren nach  
Ordner "easy-rsa" kopieren nach  
  /etc/openvpn  
  /etc/openvpn  
Zeile 44: Zeile 45:
Dann die Datei "vars" wie folgt editieren:
Dann die Datei "vars" wie folgt editieren:


[CODE]# easy-rsa parameter settings
<div style="margin: 0; margin-top:10px; margin-right:10px; border: 4px solid #ffffff; padding: 0em 1em 1em 1em; background-color:#1B1C2D; align:right;">
 
# easy-rsa parameter settings
# NOTE: If you installed from an RPM,
# don't edit this file in place in
# /usr/share/openvpn/easy-rsa --
# instead, you should copy the whole
# easy-rsa directory to another location
# (such as /etc/openvpn) so that your
# edits will not be wiped out by a future
# OpenVPN package upgrade.
 
# This variable should point to
# the top level of the easy-rsa
# tree.
export EASY_RSA="`pwd`"
 
#
# This variable should point to
# the requested executables
#
export OPENSSL="openssl"
export PKCS11TOOL="pkcs11-tool"
export GREP="grep"
 
 
# This variable should point to
# the openssl.cnf file included
# with easy-rsa.
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`


# Edit this variable to point to
# NOTE: If you installed from an RPM,
# your soon-to-be-created key
# don't edit this file in place in
# directory.
# /usr/share/openvpn/easy-rsa --
#
# instead, you should copy the whole
# WARNING: clean-all will do
# easy-rsa directory to another location
# a rm -rf on this directory
# (such as /etc/openvpn) so that your
# so make sure you define
# edits will not be wiped out by a future
# it correctly!
# OpenVPN package upgrade.
export KEY_DIR="$EASY_RSA/[B][COLOR="#FF0000"]keys[/COLOR][/B]"
 
# This variable should point to
# Issue rm -rf warning
# the top level of the easy-rsa
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR
# tree.
 
export EASY_RSA="`pwd`"
# PKCS11 fixes
export PKCS11_MODULE_PATH="dummy"
#
export PKCS11_PIN="dummy"
# This variable should point to
 
# the requested executables
# Increase this to 2048 if you
#
# are paranoid.  This will slow
export OPENSSL="openssl"
# down TLS negotiation performance
export PKCS11TOOL="pkcs11-tool"
# as well as the one-time DH parms
export GREP="grep"
# generation process.
export KEY_SIZE=1024
 
# This variable should point to
# In how many days should the root CA key expire?
# the openssl.cnf file included
export CA_EXPIRE=3650
# with easy-rsa.
 
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
# In how many days should certificates expire?
export KEY_EXPIRE=3650
# Edit this variable to point to
 
# your soon-to-be-created key
# These are the default values for fields
# directory.
# which will be placed in the certificate.
#
# Don't leave any of these fields blank.
# WARNING: clean-all will do
export KEY_COUNTRY="[B][COLOR="#FF0000"]DE[/COLOR][/B]"
# a rm -rf on this directory
export KEY_PROVINCE="[B][COLOR="#FF0000"]ZD[/COLOR][/B]"
# so make sure you define
export KEY_CITY="[B][COLOR="#FF0000"]ZDTOWN[/COLOR][/B]"
# it correctly!
export KEY_ORG="[COLOR="#FF0000"][B]Zebradem[/B][/COLOR]"
export KEY_DIR="$EASY_RSA/keys"
export KEY_EMAIL="[B][COLOR="#FF0000"][email protected][/COLOR][/B]"
 
# Issue rm -rf warning
export OPENVPN=openvpn[/CODE]
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR  
# PKCS11 fixes
export PKCS11_MODULE_PATH="dummy"
export PKCS11_PIN="dummy"  
# Increase this to 2048 if you
# are paranoid.  This will slow
# down TLS negotiation performance
# as well as the one-time DH parms
# generation process.
export KEY_SIZE=1024
# In how many days should the root CA key expire?
export CA_EXPIRE=3650
# In how many days should certificates expire?
export KEY_EXPIRE=3650
# These are the default values for fields
# which will be placed in the certificate.
# Don't leave any of these fields blank.
export KEY_COUNTRY="DE"
export KEY_PROVINCE="ZD"
export KEY_CITY="ZDTOWN"
export KEY_ORG="]Zebradem"
export KEY_EMAIL="[email protected]"
export OPENVPN=openvpn
</div>




Nun geht es an das erstellen der Zertifikate.
Nun geht es an das erstellen der Zertifikate.
Wenn man in der Konsole beim erstellen etwas eingeben muss, kann man einfach immer "[COLOR="#FFFFE0"][B]ENTER[/B][/COLOR]" drücken.
Wenn man in der Konsole beim erstellen etwas eingeben muss, kann man einfach immer "ENTER" drücken.
[COLOR="#FF0000"][B]Ausnahme[/B][/COLOR]: Wenn gefragt wird, ob Clientzertifikate Signiert werden sollen --> mit "[B][COLOR="#FFFFE0"]y[/COLOR][/B]" (yes) bestätigen!!
Ausnahme:  
Wenn gefragt wird, ob Clientzertifikate Signiert werden sollen --> mit "y" (yes) bestätigen!!


In der Konsole wechsel nach
In der Konsole wechsel nach
[CODE]/etc/openvpn/easy-rsa/2.0[/CODE]
/etc/openvpn/easy-rsa/2.0




Zeile 127: Zeile 131:
****************************************
****************************************


[CODE]. ./vars
. ./vars
./clean-all ## ACHTUNG!! löscht Inhalt von Keys Verzeichnis, nur beim ersten mal ausführen !![/CODE]
./clean-all ## ACHTUNG!! löscht Inhalt von Keys Verzeichnis, nur beim ersten mal ausführen !!




Zeile 134: Zeile 138:
****************************
****************************


[CODE]./build-ca[/CODE]
./build-ca




Zeile 141: Zeile 145:
**********************************
**********************************


[CODE]./build-dh[/CODE]
./build-dh




Zeile 148: Zeile 152:
****************************************************
****************************************************


[CODE]./build-key-server server[/CODE]
./build-key-server server
 




Zeile 156: Zeile 159:
****************************************************************
****************************************************************


[CODE]./build-key client01[/CODE]
./build-key client01




[COLOR="#FFFFE0"]Zertifikate liegen nun in "/etc/openvpn/easy-rsa/2.0/keys"
Zertifikate liegen nun in "/etc/openvpn/easy-rsa/2.0/keys"
[/COLOR]
 




Zeile 166: Zeile 169:
***************************************************************
***************************************************************


[CODE]./build-key-pass client01
./build-key-pass client01
[/CODE]
 




Für Client benötigte Zertifikate und Dateien:
Für Client benötigte Zertifikate und Dateien:
[COLOR="#FFFFE0"]
 
ca.crt
ca.crt
client01.crt
client01.crt
client01.key[/COLOR]
client01.key




Zeile 182: Zeile 185:
Für Server benötigte Zertifikate und Dateien:
Für Server benötigte Zertifikate und Dateien:


[COLOR="#FFFFE0"]ca.crt
ca.crt
server.crt
server.crt
server.key
server.key
dh1024.pem
dh1024.pem
[/COLOR]
 


Nun gehts in Freetz weiter :)
Nun gehts in Freetz weiter :)

Version vom 23. September 2011, 23:32 Uhr


Das Board mit Freiheiten




Freetz@OpenVPN

Howto für OpenVPN mit Server@Freetz und Client@Windows. Damit ein "echtes" VPN gestrickt werden kann erkläre ich hier das ganze mit Zertifikaten zur Authentifizierung.

Es geht auch mit Key-Auhtentification, allerdings kann dann immer nur ein CLient auf den Server connecten. Mit Zertifikaten können beliebig viele VPN CLients gleichzeitig verbunden werden.

Alle Befehle gebe ich per SSH Konsole ein, Files werden per SSH/WinSCP kopiert und editiert. Darauf gehe ich hier nicht weiter ein. Wer damit Probleme hat wird hier im Freetz/FAQ Bereich fündig.


Benötigt:

Image für Fritzbox mit OpenVPN OpenVPN Client für Windows, z.B. SecurepointSSLVPN_RC3

Zum erstellen der Zertifikate für Server und Clients hab ich mir auf meinem Debian Server zusäzlich OpenVPN installiert:

Als "root" am Server angemeldet folgendes in der Konsole ausführen:

apt-get install openvpn openssl

Wenn alles installiert ist, mit WinSCP folgenden Ordner erstellen:

/etc/openvpn

Mit WinSCP wechseln nach

/usr/share/doc/openvpn/examples

Ordner "easy-rsa" kopieren nach

/etc/openvpn 

Wechseln nach:

/etc/openvpn/easy-rsa/2.0

Hier den Ordner "keys" anlegen.

Dann die Datei "vars" wie folgt editieren:

# easy-rsa parameter settings
# NOTE: If you installed from an RPM,
# don't edit this file in place in
# /usr/share/openvpn/easy-rsa --
# instead, you should copy the whole
# easy-rsa directory to another location
# (such as /etc/openvpn) so that your
# edits will not be wiped out by a future
# OpenVPN package upgrade.

# This variable should point to
# the top level of the easy-rsa
# tree.
export EASY_RSA="`pwd`"

#
# This variable should point to
# the requested executables
#
export OPENSSL="openssl"
export PKCS11TOOL="pkcs11-tool"
export GREP="grep"


# This variable should point to
# the openssl.cnf file included
# with easy-rsa.
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`

# Edit this variable to point to
# your soon-to-be-created key
# directory.
#
# WARNING: clean-all will do
# a rm -rf on this directory
# so make sure you define
# it correctly!
export KEY_DIR="$EASY_RSA/keys"

# Issue rm -rf warning
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR 

# PKCS11 fixes
export PKCS11_MODULE_PATH="dummy"
export PKCS11_PIN="dummy" 

# Increase this to 2048 if you
# are paranoid.  This will slow
# down TLS negotiation performance
# as well as the one-time DH parms
# generation process.
export KEY_SIZE=1024

# In how many days should the root CA key expire?
export CA_EXPIRE=3650

# In how many days should certificates expire?
export KEY_EXPIRE=3650

# These are the default values for fields
# which will be placed in the certificate.
# Don't leave any of these fields blank.
export KEY_COUNTRY="DE"
export KEY_PROVINCE="ZD"
export KEY_CITY="ZDTOWN"
export KEY_ORG="]Zebradem"
export KEY_EMAIL="[email protected]"

export OPENVPN=openvpn


Nun geht es an das erstellen der Zertifikate. Wenn man in der Konsole beim erstellen etwas eingeben muss, kann man einfach immer "ENTER" drücken.

Ausnahme: 
Wenn gefragt wird, ob Clientzertifikate Signiert werden sollen --> mit "y" (yes) bestätigen!!

In der Konsole wechsel nach

/etc/openvpn/easy-rsa/2.0


vars einlesen und die CA initialisieren:

. ./vars
./clean-all ## ACHTUNG!! löscht Inhalt von Keys Verzeichnis, nur beim ersten mal ausführen !!


CA-Key und CA-Cert erzeugen:

./build-ca


Diffie-Hellman Parameter erzeugen:

./build-dh


Erzeugen von Server-Schlüsselpaar direkt von der CA:

./build-key-server server


Erzeugen eines Client-Schlüsselpaars (ohne Passwort), für jeden CLient eindeutigen Namen oder aufsteigende Nummer angeben:

./build-key client01


Zertifikate liegen nun in "/etc/openvpn/easy-rsa/2.0/keys"


Wenn man Clientzertifikate mit Passwortschutz erstellen möchte:

./build-key-pass client01


Für Client benötigte Zertifikate und Dateien:

ca.crt
client01.crt
client01.key


Die 3 Dateien für den Client auf einen USB-Stick oder Client-Rechner kopieren.


Für Server benötigte Zertifikate und Dateien:

ca.crt
server.crt
server.key
dh1024.pem


Nun gehts in Freetz weiter :)


OpenVPN Einstellungen öffnen, Optionen wie folgt setzen:

[x] Automatisch [x] Server [x] UDP [x] Brücke(TAP) Port: 1194 [x] Zertifikate Cipher: Blowfish

Lokale IP-Adresse: [COLOR="#FFFFE0"]10.8.0.1[/COLOR] (Dies wird die virtuelle IP vom Server) Netzmaske: [COLOR="#FFFFE0"]255.255.255.0[/COLOR] DHCP-Range: [COLOR="#FFFFE0"]10.8.0.150 10.8.0.160[/COLOR] (Je nach bedarf der virtuelle IP Bereich für Clients) Lokales Netz: [COLOR="#FFFFE0"]192.168.178.0 255.255.255.0[/COLOR] (Tatsächlicher IP Bereich des LAN, das von außen erreichbar sein soll)

[x] Erweiterte CLientkonfiguration (nicht unbedingt nötig, aber so wird es eine Runde Sache)

Client01 | [COLOR="#FFFFE0"]10.8.0.150[/COLOR] | [COLOR="#FFFFE0"]192.168.88.0 255.255.255.0[/COLOR] (Zuletzt wieder das echte LAN des Client)

Client02 | [COLOR="#FFFFE0"]10.8.0.151[/COLOR] | [COLOR="#FFFFE0"]192.168.55.0 255.255.255.0[/COLOR]

Client03 | [COLOR="#FFFFE0"]10.8.0.152[/COLOR] | [COLOR="#FFFFE0"]192.168.33.0 255.255.255.0[/COLOR]


Falls die Clients sich auch sehen sollen:

[x] Client-zu-Client

Anzahl der Maximalen CLients angeben.

DNS Server: [COLOR="#FFFFE0"]10.8.0.1[/COLOR]

Den Rest so lassen wie er ist und speichern.

Mit WinSCP die folgenden Dateien öffnen und jeweils den gesamten Inhalt an genannte Stelle kopieren:

server.crt --> Box Cert (übernehmen) ca.crt --> CA Cert (übernehmen) dh1024.pem --> DH Param (übernehmen) server.key --> Private Key (übernehmen)

Unter OpenVPN/CRL einfach einmal "Übernehmen" drücken, damit eine leere Datei erzeugt wird. Sonst startet OpenVPN nicht!


AVM-Firewall Settings:

[COLOR="#FFFFE0"]lowinput sowie highoutput gleich einstellen[/COLOR]:

Quelle --> any Ziel --> any Protokoll --> UDP Start- und End-Port --> 1194 Aktion --> permit (übernehmen)


Port Forwarding:

Protokoll --> UDP Ziel --> Fritz!Box Quell Port --> 1194 Ziel Port --> 1194 (übernehmen)

Fritzbox neu starten.


Weiter auf Client Rechner:

SecurepointSSLVPN_RC3 installieren.

VPN Client starten, neue Konfig anlegen:

Name IP des Server (DynDns Adresse)

Root CA = ca.crt Zertifikat = client01.crt Schlüssel = client01.key [x] Server Zertifikat

[ ] Auth user/pass (Haken entfernen!)

Rest so lassen, "Next" und "Finish" drücken.

Neu erstellte Konfig mit rechter Maustaste anklicken --> Editieren wählen

"DEV" von "tun" auf "tap" umstellen, "OK" klicken.

Wenn dies alles erledigt ist, am besten mal eine Sicherung der Freetz Settings sowie ein Export der Client-VPN-

Settings durchführen. War ja nun auch genug Arbeit ;)


Wenn man einen anderen Router als Client zum VPN Server verbindet, sollten beide LANs untereinander ereichbar sein. Wenn ein PC den Client darstellt, gibt es noch folgenden Trick:

Regedit auf Client-Rechner starten.

[COLOR="#FFFFE0"]HKEY_LOCAL_MACHINE\ System\ CurrentControlSet\ Services\ Tcpip\ Parameters[/COLOR]

Eintrag "[COLOR="#FFFFE0"]IPEnableRouter[/COLOR]" Wert auf[COLOR="#FFFFE0"] 1[/COLOR] setzen.

Rechner neu starten.

Gateway der übrigen Rechner im CLient LAN auf die IP des Client Rechner setzen.

Nun sollte man schön hin und her Pingen können...