Deutsch/Netzwerk/Virtuelles Privates Netz (VPN) Debian snom howto
From Snom User Wiki
Contents |
OpenVPN Debian/snom Howto
Author: SK
Dieses Dokument beschreibt die Installation und Konfiguration von OpenVPN mit zertifikatbasierter Authentifizierung unter Debian GNU Linux (4.0 etch) und das Erstellen und zur Verfügung stellen eines VPN-Tarball für das snom370-/snom820-VPN. Für diejenigen, die sich den Installations- und Konfigurationsaufwand sparen möchten, bietet die Firma Ciphron (www.ciphron.de) eine out-of-the-box-Lösung, die Ciphwall, an.
Installation von OpenVPN und easy-rsa
Unter Debian stehen vorkompilierte Pakete zur Verfügung. Sie stellen die einfachste Variante da um OpenVPN zu installieren.
Update der Paketquellen
~# apt-get update Get:1 http://ftp.de.debian.org etch Release.gpg [386B] Hit http://ftp.de.debian.org etch Release Ign http://ftp.de.debian.org etch/main Packages/DiffIndex Ign http://ftp.de.debian.org etch/non-free Packages/DiffIndex Ign http://ftp.de.debian.org etch/main Sources/DiffIndex Ign http://ftp.de.debian.org etch/non-free Sources/DiffIndex Hit http://ftp.de.debian.org etch/main Packages Hit http://ftp.de.debian.org etch/non-free Packages Hit http://ftp.de.debian.org etch/main Sources Hit http://ftp.de.debian.org etch/non-free Sources Fetched 1B in 0s (2B/s) Reading package lists... Done ~#
Installation der OpenVPN Pakete
~# apt-get install openvpn Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: liblzo2-2 The following NEW packages will be installed: liblzo2-2 openvpn 0 upgraded, 2 newly installed, 0 to remove and 30 not upgraded. Need to get 397kB of archives. After unpacking 1114kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://ftp.de.debian.org etch/main liblzo2-2 2.02-2 [59.5kB] Get:2 http://ftp.de.debian.org etch/main openvpn 2.0.9-4etch1 [338kB] Fetched 397kB in 1s (354kB/s) Preconfiguring packages ... Selecting previously deselected package liblzo2-2. (Reading database ... 44213 files and directories currently installed.) Unpacking liblzo2-2 (from .../liblzo2-2_2.02-2_i386.deb) ... Selecting previously deselected package openvpn. Unpacking openvpn (from .../openvpn_2.0.9-4etch1_i386.deb) ... Setting up liblzo2-2 (2.02-2) ... Setting up openvpn (2.0.9-4etch1) ... Starting virtual private network daemon:. ~#
Kopieren von easy-rsa
~# cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/openvpn/easy-rsa
Konfiguration von OpenVPN
OpenVPN unter Debian lädt alle Dateien die im Verzeichnis /etc/openvpn/ auf .conf enden als Konfigurationsdatei.
Erstellen der OpenVPN-Konfigurationsdatei für den Server
~# touch /etc/openvpn/server1194udp.conf
Die Datei kann nun mit jedem beliebigen Editor geöffnet und bearbeitet werden.
~# vi /etc/openvpn/server1194udp.conf
Der folgende Inhalt soll in die Datei eingefügt werden:
port 1194 proto udp dev tun ca keys/ca.crt cert keys/server.crt key keys/server.key dh keys/dh1024.pem server 10.0.0.0 255.255.255.0 client-config-dir ccd ifconfig-pool-persist ipp.txt client-to-client keepalive 10 120 persist-key persist-tun status /var/log/openvpn-status.log verb 6
Erstellen der OpenVPN-Konfigurationsdatei für den Client / das Telefon
Die Client Konfigurationsdatei ist für alles Clients / Telefone gleich aufgebaut. Damit die Konfigurationsdatei der Clients mit der Konfigurationsdatei des Server nicht im gleichen Verzeichnis liegt soll der Unterordner client-config erstellt werden:
~# mkdir /etc/openvpn/client-config ~# mkdir /etc/openvpn/client-config/tmp
Die Konfigurationsdatei muss auf dem Telefon später vpn.cnf heissen:
~# touch /etc/openvpn/client-config/vpn.cnf
Die Datei kann nun mit jedem beliebigen Editor bearbeitet werden
~# vi /etc/openvpn/client-config/vpn.cnf
Der folgende Inhalt soll in die Datei eingefügt werden, der Wert unter remote muss durch die IP-Adresse oder den Namen des Servers ausgetauscht werden:
client dev tun proto udp remote <Server-IP/-name> 1194 resolv-retry infinite nobind persist-key persist-tun ca /openvpn/ca.crt cert /openvpn/client.crt key /openvpn/client.key ns-cert-type server verb 0 ping 10 ping-restart 60
Erstellen der Zertifikate mit easy-rsa
Anpassen der easy-rsa Konfiguration
~# vi /etc/openvpn/easy-rsa/vars
Der Wert für KEY_DIR muss an die server1194udp.conf angepasst werden:
export KEY_DIR="$EASY_RSA/../keys"
Die Werte, die bei der Zertifikatserstellung übergeben werden, müssen individuell angepasst werden. Hier ein Beispiel:
export KEY_COUNTRY="DE" export KEY_PROVINCE="BLN" export KEY_CITY="Berlin" export KEY_ORG="snom technology AG" export KEY_EMAIL="noreply@snom.com"
Erstellen von Zertifikaten mit easy-rsa
~# cd /etc/openvpn/easy-rsa ~# source ./vars ~# ./clean-all
Erstellen des ca-Zertifikat
Nachdem alles Vorbereitet wurde die Zertifikate zu erstellen, muss das CA erstellt werden. Hier muss nochmal individuell angepasst werden:
~# ./build-ca Generating a 1024 bit RSA private key ................++++++ ................++++++ writing new private key to 'ca.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [US]: DE State or Province Name (full name) [CA]: BLN Locality Name (eg, city) [SanFrancisco]: Berlin Organization Name (eg, company) [Fort-Funston]: snom technology AG Organizational Unit Name (eg, section) []: Administration Common Name (eg, your name or your server's hostname) [Fort-Funston CA]: <Servername or IP> Email Address [me@myhost.mydomain]: noreply@snom.com ~#
Erstellen des Server-Zertifikat
Wie auch beim CA werden nochmal die einzelnen Abfragen gestartet, die analog zu dem vorherigen angaben anzugeben sind.
~# ./build-key-server server Country Name (2 letter code) [US]:DE State or Province Name (full name) [CA]:BLN Locality Name (eg, city) [SanFrancisco]:Berlin Organization Name (eg, company) [Fort-Funston]:snom technology AG Organizational Unit Name (eg, section) []:Administration Common Name (eg, your name or your server's hostname) [server]: <Servername or IP> Email Address [me@myhost.mydomain]:noreply@snom.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /etc/openvpn/easy-rsa/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'DE' stateOrProvinceName :PRINTABLE:'BLN' localityName :PRINTABLE:'Berlin' organizationName :PRINTABLE:'snom technology AG' organizationalUnitName:PRINTABLE:'Administration' commonName :PRINTABLE:'openvpn.intern.snom.de' ← ein Beispiel emailAddress :IA5STRING:'noreply@snom.com' Certificate is to be certified until Oct 21 12:04:51 2018 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated
Diffie Hellman Parameter erstellen
~# ./build-dh Generating DH parameters, 1024 bit long safe prime, generator 2 This is going to take a long time ..+.[...] [...]....+.... ~#
Zertifikate für Clients/Telefone erstellen
Jeder Client/Telefon sollte ein eigenes Zertifikat erhalten. Deshalb ist es wichtig den Zertifikaten eindeutige Namen zu geben um die erstellten Zertifikate unterscheiden zu können. Bei den Telefonen bietet sich die MAC-Adresse an. Als Beispiel hier die MAC-Adresse eines Telefons 0004132FFFFF.
~# ./build-key 0004132FFFFF Generating a 1024 bit RSA private key .............++++++ ....................................++++++ writing new private key to '0004132FFFFF.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [US]:DE State or Province Name (full name) [CA]:BLN Locality Name (eg, city) [SanFrancisco]:Berlin Organization Name (eg, company) [Fort-Funston]:snom technology AG Organizational Unit Name (eg, section) []:Administration Common Name (eg, your name or your server's hostname) [0004132FFFFF]: Email Address [me@myhost.mydomain]:noreply.snom.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /etc/openvpn/easy-rsa/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'DE' stateOrProvinceName :PRINTABLE:'BLN' localityName :PRINTABLE:'Berlin' organizationName :PRINTABLE:'snom technology AG' organizationalUnitName:PRINTABLE:'Administration' commonName :PRINTABLE:'0004132FFFFF' emailAddress :IA5STRING:'noreply.snom.com' Certificate is to be certified until Oct 21 12:32:41 2018 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated ~#
Starten des OpenVPN-Servers
OpenVPN wird unter Debian, nach der Installation, automatisch beim Systemstart mit gestartet. Nachdem nun die Konfiguration existiert und angepasst wurde muss der Dienst neu gestartet werden.
~# /etc/init.d/openvpn restart
Bereitstellen des VPN-Tarball für die Telefone
Die Telefone brauchen die Konfigurationsdatei und Zertifikate in einem Tarball verpackt. Dieses Tarball muss dem Telefon über einen Webserver zur Verfügung gestellt werden.
Installation des Apache-Webserver
~# apt-get install apache2 Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: apache2-mpm-worker apache2-utils apache2.2-common libapr1 libaprutil1 libpq4 libsqlite3-0 The following NEW packages will be installed: apache2 apache2-mpm-worker apache2-utils apache2.2-common libapr1 libaprutil1 libpq4 libsqlite3-0 0 upgraded, 8 newly installed, 0 to remove and 30 not upgraded. Need to get 2420kB of archives. After unpacking 5993kB of additional disk space will be used. Do you want to continue [Y/n]? Get:1 http://ftp.de.debian.org etch/main libapr1 1.2.7-8.2 [109kB] Get:2 http://ftp.de.debian.org etch/main libpq4 8.1.11-0etch1 [277kB] Get:3 http://ftp.de.debian.org etch/main libsqlite3-0 3.3.8-1.1 [194kB] Get:4 http://ftp.de.debian.org etch/main libaprutil1 1.2.7+dfsg-2 [68.5kB] Get:5 http://ftp.de.debian.org etch/main apache2-utils 2.2.3-4+etch5 [342kB] Get:6 http://ftp.de.debian.org etch/main apache2.2-common 2.2.3-4+etch5 [964kB] Get:7 http://ftp.de.debian.org etch/main apache2-mpm-worker 2.2.3-4+etch5 [424kB] Get:8 http://ftp.de.debian.org etch/main apache2 2.2.3-4+etch5 [41.5kB] Fetched 2420kB in 4s (501kB/s) Selecting previously deselected package libapr1. (Reading database ... 44318 files and directories currently installed.) Unpacking libapr1 (from .../libapr1_1.2.7-8.2_i386.deb) ... Selecting previously deselected package libpq4. Unpacking libpq4 (from .../libpq4_8.1.11-0etch1_i386.deb) ... Selecting previously deselected package libsqlite3-0. Unpacking libsqlite3-0 (from .../libsqlite3-0_3.3.8-1.1_i386.deb) ... Selecting previously deselected package libaprutil1. Unpacking libaprutil1 (from .../libaprutil1_1.2.7+dfsg-2_i386.deb) ... Selecting previously deselected package apache2-utils. Unpacking apache2-utils (from .../apache2-utils_2.2.3-4+etch5_i386.deb) ... Selecting previously deselected package apache2.2-common. Unpacking apache2.2-common (from .../apache2.2-common_2.2.3-4+etch5_i386.deb) ... Selecting previously deselected package apache2-mpm-worker. Unpacking apache2-mpm-worker (from .../apache2- mpm-worker_2.2.3-4+etch5_i386.deb) ... Selecting previously deselected package apache2. Unpacking apache2 (from .../apache2_2.2.3-4+etch5_all.deb) ... Setting up libapr1 (1.2.7-8.2) ... Setting up libpq4 (8.1.11-0etch1) ... Setting up libsqlite3-0 (3.3.8-1.1) ... Setting up libaprutil1 (1.2.7+dfsg-2) ... Setting up apache2-utils (2.2.3-4+etch5) ... Setting up apache2.2-common (2.2.3-4+etch5) ... Setting Apache2 to Listen on port 80. If this is not desired, please edit /etc/apache2/ports.conf as desired. Note that the Port directive no longer works. Module alias installed; run /etc/init.d/apache2 force-reload to enable. Module autoindex installed; run /etc/init.d/apache2 force-reload to enable. Module dir installed; run /etc/init.d/apache2 force-reload to enable. Module env installed; run /etc/init.d/apache2 force-reload to enable. Module mime installed; run /etc/init.d/apache2 force-reload to enable. Module negotiation installed; run /etc/init.d/apache2 force-reload to enable. Module setenvif installed; run /etc/init.d/apache2 force-reload to enable. Module status installed; run /etc/init.d/apache2 force-reload to enable. Module auth_basic installed; run /etc/init.d/apache2 force-reload to enable. Module authz_default installed; run /etc/init.d/apache2 force-reload to enable. Module authz_user installed; run /etc/init.d/apache2 force-reload to enable. Module authz_groupfile installed; run /etc/init.d/apache2 force-reload to enable. Module authn_file installed; run /etc/init.d/apache2 force-reload to enable. Module authz_host installed; run /etc/init.d/apache2 force-reload to enable. Setting up apache2-mpm-worker (2.2.3-4+etch5) ... Starting web server (apache2).... Setting up apache2 (2.2.3-4+etch5) ...
Erstellen eines Unterordners
~# mkdir /var/www/openvpn ~#
Anpassen der Apache Konfiguration:
~# vi /etc/apache2/sites-available/default
Folgenden Wert suchen:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>
Dann den AllowOverride wie folgt ändern:
AllowOverride ALL
Erstellen des VPN-Tarball
Als Beispiel nehme ich wieder das Telefon mit der MAC-Adresse 0004132FFFFF für das schon das Zertifikat erstellt wurde.
~# cp /etc/openvpn/client-config/vpn.cnf /etc/openvpn/client-config/tmp/ ~# cp /etc/openvpn/keys/0004132FFFFF.crt /etc/openvpn/client-config/tmp/client.crt ~# cp /etc/openvpn/keys/0004132FFFFF.key /etc/openvpn/client-config/tmp/client.key ~# cp /etc/openvpn/keys/ca.crt /etc/openvpn/client-config/tmp/ca.crt ~# cd /etc/openvpn/client-config/tmp/ ~# chown -Rf root:root * ~# chmod -R 700 * ~# tar cvpf vpnclient-0004132FFFFF.tar * ~# rm client.*
Veröffentlichen des VPN-Tarball
Erstellen eines Ordners für das individuelle Tarball
~# mkdir /var/www/openvpn/0004132FFFFF
Sichern des Verzeichnis
~# touch /var/www/openvpn/0004132FFFFF/.htaccess ~# vi /var/www/openvpn/0004132FFFFF/.htaccess
Der folgende Inhalt soll in die Datei eingefügt werden:
AuthType Basic AuthName "0004132FFFFF" AuthUserFile .htpasswd Require user 0004132FFFFF
Password für 0004132FFFFF setzen.
~# htpasswd /etc/apache2/.htpasswd 0004132FFFFF
Verschieben des Tarballs:
~# mv /etc/openvpn/client-config/tmp/vpnclient-0004132FFFFF.tar /var/www/openvpn/0004132FFFFF/
Konfiguration des Telefons
VPN-Einstellungen
Die VPN-Einstellungen sind unter Einstellungen → QOS/Sicherheit → Sicherheit zu finden. Der Punkt VPN muss auf „ein“ gestellt sein. In das Feld „Unkomprimierter VPN Konfig. Tarball:“ muss folgendes, für unser Beispiel mit der MAC 0004132FFFFF, eingetragen werden: http://<IP-Adresse des Servers>/openvpn/0004132FFFFF/vpnclient-0004132FFFFF.tar
Identitätseinstellungen

In der Annahme, dass sich der OpenVPN-Server auf dem gleichen Server wie des SIP-Servers befindet, muss nun die IP-Adresse des tun-Device ermittelt werden.
~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.10.59 Bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: 2001:db8::20c:29ff:fedb:1a9b/64 Scope:Global
inet6 addr: fe80::20c:29ff:fedb:1a9b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10330779 errors:0 dropped:0 overruns:0 frame:0
TX packets:2582071 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:954308825 (910.0 MiB) TX bytes:515281166 (491.4 MiB)
Interrupt:177 Base address:0x1400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1425 errors:0 dropped:0 overruns:0 frame:0
TX packets:1425 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:767072 (749.0 KiB) TX bytes:767072 (749.0 KiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.0.1 P-t-P:10.0.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3062 (2.9 KiB) TX bytes:4177 (4.0 KiB)
Das tun0 ist in diesem Beipiel das OpenVPN Tunnel Device. Die IP-Adresse nach „inet addr:“ ist die IP-Adresse (10.0.0.1) unter der der Server zu erreichen ist.

In den Identitätseinstellungen muss diese IP-Adresse als Registrar und Proxy angegeben werden.
