{"id":425,"date":"2015-03-09T18:44:14","date_gmt":"2015-03-09T17:44:14","guid":{"rendered":"http:\/\/www.schoen-bloed.at\/blog\/?p=425"},"modified":"2018-05-06T09:14:29","modified_gmt":"2018-05-06T08:14:29","slug":"wie-richte-ich-openvpn-auf-einem-ubiquiti-edgerouter-ein","status":"publish","type":"post","link":"https:\/\/www.schoen-bloed.at\/blog\/2015\/03\/wie-richte-ich-openvpn-auf-einem-ubiquiti-edgerouter-ein\/","title":{"rendered":"Wie richte ich OpenVPN auf einem UBIQUITI EdgeRouter ein?"},"content":{"rendered":"<p>Kurz vorne weg, der <a href=\"https:\/\/www.ubnt.com\/\">UBIQUITI<\/a> EdgeRouter ist ein kleiner Hardware Router der als Basis <a href=\"https:\/\/www.debian.org\/\">Debian<\/a> mit <a href=\"https:\/\/de.wikipedia.org\/wiki\/Vyatta_Open-Firmware-Router\">Vyatta<\/a> verwendet. Ich hab\u00a0mehrere\u00a0<a title=\"UbiQuiti EdgeRouter Lite, 3-port Router\" href=\"http:\/\/www.amazon.de\/gp\/product\/B00CSML06Q\/ref=as_li_tl?ie=UTF8&amp;camp=1638&amp;creative=19454&amp;creativeASIN=B00CSML06Q&amp;linkCode=as2&amp;tag=itr04-21&amp;linkId=QRNUBFNYNAC65T7Y\" target=\"_blank\" rel=\"noopener\">UbiQuiti EdgeRouter Lite, 3-port Router<\/a> im Einsatz.<\/p>\n<p>In diesem Beitrag gehe ich auf die Konfiguration des EdgeRouters ein und setze OpenVPN Kenntnisse voraus.<\/p>\n<p><!--more--><\/p>\n<p>Als erstes ben\u00f6tigen wir eine CA sowie die Keys f\u00fcr den Server und den ersten Client. Wir benutzen daf\u00fcr die von OpenVPN mitgebrachten easyca Scripte. Als erstes wird die &#8222;vars&#8220; Datei bearbeitet damit alle Basiswerte stimmen. Erstellen wir den Diffie Hellman key und die Certificate Authority.<\/p>\n<p><code>\/schoenbloed# touch index.txt<br \/>\n\/schoenbloed# echo 01 &gt; serial<\/code><\/p>\n<p>Erstellen des DH Keys<\/p>\n<p><code>\/schoenbloed# ..\/build-dh<br \/>\nGenerating DH parameters, 1024 bit long safe prime, generator 2<br \/>\nThis is going to take a long time<br \/>\n..................+.................................................<\/code><\/p>\n<p>Erstellen der CA<\/p>\n<p><code>\/schoenbloed # ..\/build-ca<br \/>\nGenerating a 1024 bit RSA private key<br \/>\n...........++++++<br \/>\n...........++++++<br \/>\nwriting new private key to 'ca.key'<br \/>\n-----<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter '.', the field will be left blank.<br \/>\n-----<br \/>\nCountry Name (2 letter code) [AT]:<br \/>\nState or Province Name (full name) []:<br \/>\nLocality Name (eg, city) [Vienna]:<br \/>\nOrganization Name (eg, company) [schoenbloed ]:<br \/>\nOrganizational Unit Name (eg, section) []:<br \/>\nCommon Name (eg, your name or your server's hostname) [schoenbloed\u00a0 CA]:<br \/>\nName []:<br \/>\nEmail Address [ich.bin@schoen-bloed.at]:<\/code><\/p>\n<p>Erstellen des Server Keys<\/p>\n<p><code>\/schoenbloed # ..\/build-key-server gwschoenbloed<br \/>\nGenerating a 2048 bit RSA private key<br \/>\n..............................+++<br \/>\n...............................................+++<br \/>\nwriting new private key to 'gwschoenbloed.key'<br \/>\n-----<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter '.', the field will be left blank.<br \/>\n-----<br \/>\nCountry Name (2 letter code) [AT]:<br \/>\nState or Province Name (full name) []:<br \/>\nLocality Name (eg, city) [Vienna]:<br \/>\nOrganization Name (eg, company) [schoenbloed]:<br \/>\nOrganizational Unit Name (eg, section) []:<br \/>\nCommon Name (eg, your name or your server's hostname) [gwschoenbloed]:<br \/>\nName []:<br \/>\nEmail Address [ich.bin@schoen-bloed.at]:<br \/>\nPlease enter the following 'extra' attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:<br \/>\nAn optional company name []:<br \/>\nUsing configuration from ..\/openssl-1.0.0.cnf<br \/>\nCheck that the request matches the signature<br \/>\nSignature ok<br \/>\nThe Subject's Distinguished Name is as follows<br \/>\ncountryName :PRINTABLE:'AT'<br \/>\nlocalityName :PRINTABLE:'Vienna'<br \/>\norganizationName :PRINTABLE:'schoenbloed'<br \/>\ncommonName :PRINTABLE:'gwschoenbloed'<br \/>\nemailAddress :IA5STRING:'ich.bin@schoen-bloed.at'<br \/>\nCertificate is to be certified until Mar 6 15:59:19 2025 GMT (3650 days)<br \/>\nSign the certificate? [y\/n]:y<br \/>\n1 out of 1 certificate requests certified, commit? [y\/n]y<br \/>\nWrite out database with 1 new entries<br \/>\nData Base Updated<\/code><\/p>\n<p>Erstellen des Client Keys<\/p>\n<p><code>\/schoenbloed# ..\/build-key client<br \/>\nGenerating a 2048 bit RSA private key<br \/>\n.................................................................+++<br \/>\n..............................+++<br \/>\nwriting new private key to 'client.key'<br \/>\n-----<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter '.', the field will be left blank.<br \/>\n-----<br \/>\nCountry Name (2 letter code) [AT]:<br \/>\nState or Province Name (full name) []:<br \/>\nLocality Name (eg, city) [Vienna]:<br \/>\nOrganization Name (eg, company) [schoenbloed]:Client<br \/>\nOrganizational Unit Name (eg, section) []:<br \/>\nCommon Name (eg, your name or your server's hostname) [client]:<br \/>\nName []:<br \/>\nEmail Address [ich.bin@schoen-bloed.at]:<\/code><\/p>\n<p>Please enter the following &#8218;extra&#8216; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:<br \/>\nAn optional company name []:<br \/>\nUsing configuration from ..\/openssl-1.0.0.cnf<br \/>\nCheck that the request matches the signature<br \/>\nSignature ok<br \/>\nThe Subject&#8217;s Distinguished Name is as follows<br \/>\ncountryName :PRINTABLE:&#8217;AT&#8216;<br \/>\nlocalityName :PRINTABLE:&#8217;Vienna&#8216;<br \/>\norganizationName :PRINTABLE:&#8217;schoenbloed&#8216;<br \/>\ncommonName :PRINTABLE:&#8217;client&#8216;<br \/>\nemailAddress :IA5STRING:&#8217;ich.bin@schoen-bloed.at&#8216;<br \/>\nCertificate is to be certified until Mar 6 16:29:01 2025 GMT (3650 days)<br \/>\nSign the certificate? [y\/n]:y<\/p>\n<p>1 out of 1 certificate requests certified, commit? [y\/n]y<br \/>\nWrite out database with 1 new entries<br \/>\nData Base Updated<\/p>\n<h1>Zur Konfiguration des Routers<\/h1>\n<p>Da der UBIQUITI EdgeRouters noch kein Webinterface zur Konfiguration von OpenVPN hat (Stand FW 1.6.0), m\u00fcssen wir uns \u00fcber ssh mit dem Router verbinden. Eingeloggt m\u00fcssen wir zu erst den DH, die CA sowie den Server Key \u00fcbertragen.<\/p>\n<p><code>ssh 192.168.1.1 -l ubnt<br \/>\nThe authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.<br \/>\nRSA key fingerprint is 35:98:71:9d:ce:2b:e5:2a:2c:87:8a:59:5f:fe:22:64.<br \/>\nAre you sure you want to continue connecting (yes\/no)? yes<br \/>\nWarning: Permanently added '192.168.1.1' (RSA) to the list of known hosts.<br \/>\nWelcome to EdgeOS<br \/>\nBy logging in, accessing, or using the Ubiquiti product, you<br \/>\nacknowledge that you have read and understood the Ubiquiti<br \/>\nLicense Agreement (available in the Web UI at, by default,<br \/>\nhttp:\/\/192.168.1.1) and agree to be bound by its terms.<\/code><\/p>\n<p>ubnt@192.168.1.1&#8217;s password:<br \/>\nLinux ubnt 3.10.20-UBNT #1 SMP Thu Oct 16 16:29:39 PDT 2014 mips64<br \/>\nWelcome to EdgeOS<br \/>\nLast login: Sun Jun 1 11:46:20 2014<br \/>\nubnt@ubnt:~$ cd \/config\/auth<br \/>\nubnt@ubnt:\/config\/auth$ mkdir schoenbloed<br \/>\nubnt@ubnt:\/config\/auth$ cd schoenbloed<br \/>\nubnt@ubnt:\/config\/auth\/schoenbloed$ cat &gt; dh1024.pem<br \/>\n&#8212;&#8211;BEGIN DH PARAMETERS&#8212;&#8211;<br \/>\n&#8230;&#8230;<br \/>\n&#8212;&#8211;END DH PARAMETERS&#8212;&#8211;&lt;strg+d&gt;<br \/>\nubnt@ubnt:\/config\/auth\/schoenbloed$ cat &gt; ca.crt<br \/>\n&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<br \/>\n&#8230;&#8230;<br \/>\n&#8212;&#8211;END CERTIFICATE&#8212;&#8211;&lt;strg+d&gt;<br \/>\nubnt@ubnt:\/config\/auth\/schoenbloed$ cat &gt; gwschoenbloed.key<br \/>\n&#8212;&#8211;BEGIN PRIVATE KEY&#8212;&#8211;<br \/>\n&#8230;&#8230;<br \/>\n&#8212;&#8211;END PRIVATE KEY&#8212;&#8211;<br \/>\nubnt@ubnt:\/config\/auth\/schoenbloed$ cat &gt; gwschoenbloed.crt<br \/>\nCertificate:<br \/>\n&#8230;&#8230;<br \/>\n&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<br \/>\n&#8230;&#8230;<br \/>\n&#8212;&#8211;END CERTIFICATE&#8212;&#8211;<br \/>\nubnt@ubnt:\/config\/auth\/schoenbloed$ configure<br \/>\nset interfaces openvpn vtun0 encryption aes256<br \/>\nset interfaces openvpn vtun0 local-port 1194<br \/>\nset interfaces openvpn vtun0 mode server<br \/>\nset interfaces openvpn vtun0 openvpn-option &#8211;comp-lzo<br \/>\nset interfaces openvpn vtun0 protocol udp<br \/>\nset interfaces openvpn vtun0 server client gwschoenbloed ip 192.168.61.10<br \/>\nset interfaces openvpn vtun0 server push-route \/24<br \/>\nset interfaces openvpn vtun0 server subnet 192.168.61.0\/24<br \/>\nset interfaces openvpn vtun0 tls ca-cert-file \/config\/auth\/schoenbloed\/ca.crt<br \/>\nset interfaces openvpn vtun0 tls cert-file \/config\/auth\/schoenbloed\/gwschoenbloed.crt<br \/>\nset interfaces openvpn vtun0 tls dh-file \/config\/auth\/schoenbloed\/dh1024.pem<br \/>\nset interfaces openvpn vtun0 tls key-file \/config\/auth\/schoenbloed\/gwschoenbloed.key<br \/>\ncommit<\/p>\n<p>Damit ist die Konfiguration des Routers abgeschlossen. Jetzt ist nur noch die Konfiguration des Clients notwendig<\/p>\n<p>Diese ist reduziert gesehen nur diese Konfigurationsdatei und die Zertifikate, ca.crt, client.key, client.crt<\/p>\n<p><code>client<br \/>\ndev tun<br \/>\nproto udp<br \/>\nremote 1194<br \/>\nresolv-retry infinite<br \/>\nnobind<br \/>\nuser nobody<br \/>\ngroup nogroup<br \/>\npersist-key<br \/>\npersist-tun<br \/>\nca ca.crt<br \/>\ncert client.crt<br \/>\nkey client.key<br \/>\ncipher AES-256-CBC<br \/>\ncomp-lzo<br \/>\nverb 3<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kurz vorne weg, der UBIQUITI EdgeRouter ist ein kleiner Hardware Router der als Basis Debian mit Vyatta verwendet. Ich hab\u00a0mehrere\u00a0UbiQuiti EdgeRouter Lite, 3-port Router im Einsatz. In diesem Beitrag gehe ich auf die Konfiguration des EdgeRouters ein und setze OpenVPN Kenntnisse voraus.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,26,25],"tags":[],"_links":{"self":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/425"}],"collection":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/comments?post=425"}],"version-history":[{"count":15,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/425\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/posts\/425\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/media?parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/categories?post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.schoen-bloed.at\/blog\/wp-json\/wp\/v2\/tags?post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}