{"id":2073,"date":"2013-10-26T12:13:00","date_gmt":"2013-10-26T10:13:00","guid":{"rendered":"http:\/\/blog.wenzlaff.de\/?p=2073"},"modified":"2021-11-22T17:15:59","modified_gmt":"2021-11-22T16:15:59","slug":"wie-kann-openvpn-auf-einem-wr-703n-unter-openwrt-eingerichtet-werden","status":"publish","type":"post","link":"http:\/\/blog.wenzlaff.de\/?p=2073","title":{"rendered":"Wie kann OpenVPN auf einem WR-703N unter OpenWrt eingerichtet werden?"},"content":{"rendered":"<p>Nach dieser guten Anleitung wie folgt vorgehen.<br \/>\n<code><br \/>\nopkg update<br \/>\nopkg install openvpn openvpn-easy-rsa openssh-sftp-server<br \/>\n<\/code><\/p>\n<p>Zertifikate erstellen:<\/p>\n<p>Optional die<br \/>\nvi <strong>\/etc\/easy-rsa\/vars<\/strong><br \/>\nf\u00fcr default vorbelegungen anpassen:<\/p>\n<p><code>export KEY_COUNTRY=\"DE\"<br \/>\nexport KEY_PROVINCE=\"Niedersachsen\"<br \/>\nexport KEY_CITY=\"Langenhagen\"<br \/>\nexport KEY_ORG=\"TWSoft\"<br \/>\nexport KEY_EMAIL=\"mail@email.de\"<br \/>\nexport KEY_EMAIL=mail@email.de<br \/>\n# Der KEY_CN mus EINDEUTIG und EINMALIG sien<br \/>\nexport KEY_CN=server.email.de<br \/>\nexport KEY_NAME=server.email.de<br \/>\nexport KEY_OU=TWSoft<br \/>\nexport PKCS11_MODULE_PATH=changeme<br \/>\nexport PKCS11_PIN=1234<\/code><\/p>\n<p>In das <strong>\/etc\/easy-rsa<\/strong> Verzeichnis wechseln.<br \/>\n<code>.\/clean-all<\/code><br \/>\nausf\u00fchren. L\u00f6scht das ganze <strong>\/etc\/easy-rsa\/keys<\/strong> Verzeichnis<\/p>\n<p><code>build-ca<\/code><\/p>\n<p>Erzeugt diese Fragen:<br \/>\nCountry Name (2 letter code) [DE]:<br \/>\nState or Province Name (full name) [DE]:Langenhagen<br \/>\nLocality Name (eg, city) [Langenhagen]:<br \/>\nOrganization Name (eg, company) [TWSoft]:<br \/>\nOrganizational Unit Name (eg, section) [TWSoft]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [EINDEUTIG.wenzlaff.de] www.wenzlaff.de<br \/>\nName [server.wenzlaff.de]:www.wenzlaff.de<br \/>\nEmail Address [mail@email.de]:<\/p>\n<p>Erstellt in <strong>\/etc\/easy-rsa\/keys<\/strong> die Dateien:<br \/>\n<strong>ca.key<br \/>\nca.crt<\/strong><\/p>\n<p>Dann<br \/>\n<strong>build-dh<\/strong><br \/>\nund ein paar Minuten warten bis in <strong>\/etc\/easy-rsa\/keys<\/strong> die<br \/>\n<strong>dh1024.pem<\/strong><br \/>\nerzeugt wurde.<\/p>\n<p>Jetzt noch die Server Key erzeugen mit:<br \/>\n<code>build-key-server server<\/code><\/p>\n<p>Und einige Fragen beantworten:<br \/>\nCountry Name (2 letter code) [DE]:<br \/>\nState or Province Name (full name) [DE]:Hannover<br \/>\nLocality Name (eg, city) [Langenhagen]:<br \/>\nOrganization Name (eg, company) [TWSoft]:<br \/>\nOrganizational Unit Name (eg, section) [TWSoft]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [server]:<br \/>\nName [server.wenzlaff.de]:<br \/>\nEmail Address [mail@email.de]:<\/p>\n<p>Please enter the following &#8218;extra&#8216; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:1234<br \/>\nAn optional company name []:TWSoft<br \/>\nUsing configuration from \/etc\/easy-rsa\/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;DE&#8216;<br \/>\nstateOrProvinceName   :PRINTABLE:&#8217;Hannover&#8216;<br \/>\nlocalityName          :PRINTABLE:&#8217;Langenhagen&#8216;<br \/>\norganizationName      :PRINTABLE:&#8217;TWSoft&#8216;<br \/>\norganizationalUnitName:PRINTABLE:&#8217;TWSoft&#8216;<br \/>\ncommonName            :PRINTABLE:&#8217;server&#8216;<br \/>\nname                  :PRINTABLE:&#8217;server.wenzlaff.de&#8216;<br \/>\nemailAddress          :IA5STRING:&#8217;mail@email.de&#8216;<br \/>\nCertificate is to be certified until Oct  2 18:00:57 2023 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<p>Nun gibt es in <strong>\/etc\/easy-rsa\/keys<\/strong> auch die<br \/>\n<strong>server.crt<br \/>\nserver.csr<br \/>\nserver.key<\/strong><\/p>\n<p>Alle erzeugten Key in eine .p12 Datei packen mit:<\/p>\n<p><code>build-key-pkcs12 thomas<\/code><\/p>\n<p>Und wieder die gewohnten Fragen beantworten:<\/p>\n<p>Country Name (2 letter code) [DE]:<br \/>\nState or Province Name (full name) [DE]:Hannover<br \/>\nLocality Name (eg, city) [Langenhagen]:<br \/>\nOrganization Name (eg, company) [TWSoft]:<br \/>\nOrganizational Unit Name (eg, section) [TWSoft]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [thomas]:<br \/>\nName [server.wenzlaff.de]:<br \/>\nEmail Address [email@mail.de]:<\/p>\n<p>Please enter the following &#8218;extra&#8216; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:4567<br \/>\nAn optional company name []:TWSoft<br \/>\nUsing configuration from <strong>\/etc\/easy-rsa\/openssl-1.0.0.cnf<\/strong><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;DE&#8216;<br \/>\nstateOrProvinceName   :PRINTABLE:&#8217;Hannover&#8216;<br \/>\nlocalityName          :PRINTABLE:&#8217;Langenhagen&#8216;<br \/>\norganizationName      :PRINTABLE:&#8217;TWSoft&#8216;<br \/>\norganizationalUnitName:PRINTABLE:&#8217;TWSoft&#8216;<br \/>\ncommonName            :PRINTABLE:&#8217;thomas&#8216;<br \/>\nname                  :PRINTABLE:&#8217;server.wenzlaff.de&#8216;<br \/>\nemailAddress          :IA5STRING:&#8217;mail@email.de&#8216;<br \/>\nCertificate is to be certified until Oct  2 17:59:08 2023 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<br \/>\nEnter Export Password: 0000<br \/>\nVerifying &#8211; Enter Export Password: 0000<\/p>\n<p>So jetzt sind auch in <strong>\/etc\/easy-rsa\/keys<\/strong> die<br \/>\n<strong>thomas.csr<br \/>\nthomas.crt<br \/>\nthomas.key<br \/>\nthomas.p12<\/strong><br \/>\nDateien f\u00fcr den Client erstellt worden.<\/p>\n<p>Jetzt m\u00fcssen die Keys noch auf den Server und den Client verteilt werden.<\/p>\n<p><code>cd \/etc\/easy-rsa\/keys<br \/>\ncp ca.crt ca.key dh1024.pem server.crt server.key \/etc\/openvpn\/<\/code><\/p>\n<p>Hier noch eine kleine Zuordungstabelle, welche Zertifikate wo hinkommen:<br \/>\n<code><br \/>\nDateiname \t    Speicherort \tBeschreibung \t        geheim<br \/>\nca.crt  \t    Server + Clients \tRoot CA Zertifikat \tNein<br \/>\nca.key \t            im Safe :) \t        Root CA Schl\u00fcssel \tJa<br \/>\ndh{Wert}.pem \t    Server \t        Diffie Hellman \t        Nein<br \/>\nserver.crt \t    Server \t        Server Zertifikat \tNein<br \/>\nserver.key \t    Server \t        Server Schl\u00fcssel \tJa<br \/>\nvpnclient01.crt     Client 1 \t        Client 1 Zertifikat \tNein<br \/>\nvpnclient01.key     Client 1 \t        Client 1 Schl\u00fcssel \tJa<br \/>\n<\/code><\/p>\n<p>Server Konfigurieren <strong>vi \/etc\/config\/openvpn<\/strong><br \/>\n<code><br \/>\nconfig 'openvpn' 'lan'<br \/>\n        option 'enable' '1'<br \/>\n        option 'port' '1194'<br \/>\n        option 'proto' 'udp'<br \/>\n        option 'dev' 'tap0'<br \/>\n        option 'ca' '\/etc\/openvpn\/ca.crt'<br \/>\n        option 'cert' '\/etc\/openvpn\/server.crt'<br \/>\n        option 'key' '\/etc\/openvpn\/server.key'<br \/>\n        option 'dh' '\/etc\/openvpn\/dh1024.pem'<br \/>\n        option 'ifconfig_pool_persist' '\/tmp\/ipp.txt'<br \/>\n        option 'keepalive' '10 120'<br \/>\n        option 'comp_lzo' '1'<br \/>\n        option 'persist_key' '1'<br \/>\n        option 'persist_tun' '1'<br \/>\n        option 'status' '\/tmp\/openvpn-status.log'<br \/>\n        option 'verb' '3'<br \/>\n        option 'server_bridge' '192.168.2.123 255.255.255.0 192.168.2.122 192.168.2.111'<br \/>\n        option 'push' 'redirect-gateway def1'<br \/>\n        list 'push' 'dhcp-option DNS 192.168.2.123'<br \/>\n<\/code><\/p>\n<p>Server Starten mit:<br \/>\n<strong>\/etc\/init.d\/openvpn start<\/strong><br \/>\nund:<br \/>\n<strong>\/etc\/init.d\/openvpn stop<\/strong><br \/>\nRestart<br \/>\n<strong>\/etc\/init.d\/openvpn restart<\/strong><\/p>\n<p>Und f\u00fcr Autostart einmal oder \u00fcber Luci:<br \/>\n<strong>\/etc\/init.d\/openvpn enable<\/strong><\/p>\n<p>Nur wenn der VPN-Server l\u00e4uft, ist \u00fcber Luci das <strong>tap0<\/strong> Device erreichbar.<\/p>\n<p>Im Firewall <strong>vi \/etc\/config\/firewall<\/strong> den Port 1194 freischalten:<\/p>\n<p><code>config 'rule'<br \/>\n        option 'target' 'ACCEPT'<br \/>\n        option 'dest_port' '1194'<br \/>\n        option 'src' 'wan'<br \/>\n        option 'proto' 'tcpudp'<br \/>\n        option 'family' 'ipv4'<\/code><\/p>\n<p><strong>\/etc\/init.d\/firewall restart<\/strong><\/p>\n<p>Adressbereich setzen <strong>vi \/etc\/config\/dhcp<\/strong><\/p>\n<p><code>config dhcp lan<br \/>\n        option interface        lan<br \/>\n        option ignore 0<br \/>\n        option start    150  # von .150 bis .199 = 49 Adressen<br \/>\n        option limit     49<br \/>\n        option leasetime        12h<\/code><\/p>\n<p><strong>reboot<\/strong><\/p>\n<p>IPhone Client Konfiguration.<br \/>\nDaf\u00fcr brauchen wir eine OpenWrt.ovpn Datei. Die m\u00fcssen wir uns aus den Zertifikaten und Key zusammenbauen:<\/p>\n<p># TW OpenWrt Configuration f\u00fcr xxx.no-ip.org IP:<br \/>\nremote xx.xxx.xxx.xxx 1194<br \/>\nclient<br \/>\ntls-client<br \/>\ndev tun # <strong>tap geht nicht mit OpenVpn App 1.01 build 88<\/strong><br \/>\nproto udp<br \/>\nremote-cert-tls server<br \/>\nresolv-retry infinite<br \/>\nnobind<br \/>\npersist-tun<br \/>\npersist-key<br \/>\npkcs12 thomas.p12<br \/>\ncomp-lzo<br \/>\nverb 3<\/p>\n<p># hier die Zertifikate von <strong>ca.crt, thomas.crt, thomas.key<\/strong> einf\u00fcgen:<br \/>\n<ca><br \/>\n&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<br \/>\nMIIEBDCCA22gAwIBAgIJAgg\/WZdmAp<br \/>\n&#8230;<br \/>\n+6VIFdXmjy19eZQJzEJFxO5+iqZ6EZhs<br \/>\n&#8212;&#8211;END CERTIFICATE&#8212;&#8211;<br \/>\n<\/ca><br \/>\n<cert><br \/>\n&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<br \/>\nMIIEQDCCA6mgAwIBAgIBAjANB<br \/>\n&#8230;<br \/>\njGlI9+MUzx3nHhhU1W1F3s4zeeS3TFmjb7xhori4J7JZugOS<br \/>\n&#8212;&#8211;END CERTIFICATE&#8212;&#8211;<br \/>\n<\/cert><br \/>\n<key><br \/>\n&#8212;&#8211;BEGIN PRIVATE KEY&#8212;&#8211;<br \/>\ngYBxm4LOI4uFPgBmS\/9zjEZ1TGyE<br \/>\n&#8230;<br \/>\nJUe0BUfOhe4x<br \/>\n&#8212;&#8211;END PRIVATE KEY&#8212;&#8211;<br \/>\n<\/key><\/p>\n<p>An dieser Stelle habe ich gemerkt, das der OpenVPN 1.01 build 88 Client f\u00fcr das iPhone, <strong>kein TAP unterst\u00fctzt<\/strong>.<br \/>\nDie von mir oben gew\u00fcnschte Bridge \u00fcber TAP-Device (virtuelle Netzwerkkarte, ethernet Adapter) ist also <strong>nicht<\/strong> m\u00f6glich.<\/p>\n<p>Also umkonfigurieren so das zumindestenst ein OpenVPN TUN l\u00e4uft.<br \/>\n<strong>Also ist kein Layer 2 Tunnel mit dieser App und dem iPhone m\u00f6glich. Schade! <\/strong><\/p>\n<p><strong>vi \/etc\/config\/openvpn<\/strong><\/p>\n<p><code>config 'openvpn' 'lan'<br \/>\n        option 'enable' '1'<br \/>\n        option 'port' '1194'<br \/>\n        option 'proto' 'udp'<br \/>\n        option 'dev' 'tun'<br \/>\n        option 'ca' '\/etc\/openvpn\/ca.crt'<br \/>\n        option 'cert' '\/etc\/openvpn\/server.crt'<br \/>\n        option 'key' '\/etc\/openvpn\/server.key'<br \/>\n        option 'dh' '\/etc\/openvpn\/dh1024.pem'<br \/>\n        option 'ifconfig_pool_persist' '\/tmp\/ipp.txt'<br \/>\n        option 'keepalive' '10 120'<br \/>\n        option 'comp_lzo' '1'<br \/>\n        option 'persist_key' '1'<br \/>\n        option 'persist_tun' '1'<br \/>\n        option 'status' '\/var\/log\/openvpn-status.log'<br \/>\n        option 'verb' '3'<br \/>\n        option 'server' '10.0.0.0 255.255.255.0'<br \/>\n        list 'push' 'redirect-gateway def1'<br \/>\n        list 'push' 'dhcp-option DOMAIN lan'<br \/>\n        list 'push' 'dhcp-option DNS 192.168.2.1'<\/code><\/p>\n<p><strong>vi \/etc\/config\/firewall<\/strong><\/p>\n<p><code>config 'include'<br \/>\noption 'path' '\/etc\/firewall.user' config 'rule'<br \/>\noption 'target' 'ACCEPT' option 'name' 'VPN'<br \/>\noption 'src' 'wan'<br \/>\noption 'proto' 'udp'<br \/>\noption 'dest_port' '1194'<\/code><\/p>\n<p><strong>vi \/etc\/firewall.user<\/strong><br \/>\n<code>iptables -t nat -A prerouting_wan -p udp --dport 1194 -j ACCEPT<br \/>\niptables -A input_wan -p udp --dport 1194 -j ACCEPT<br \/>\niptables -I INPUT -i tun+ -j ACCEPT<br \/>\niptables -I FORWARD -i tun+ -j ACCEPT<br \/>\niptables -I OUTPUT -o tun+ -j ACCEPT<br \/>\niptables -I FORWARD -o tun+ -j ACCEPT<\/code><\/p>\n<p><strong>Connect im iPhone l\u00e4uft schon mal.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nach dieser guten Anleitung wie folgt vorgehen. opkg update opkg install openvpn openvpn-easy-rsa openssh-sftp-server Zertifikate erstellen: Optional die vi \/etc\/easy-rsa\/vars f\u00fcr default vorbelegungen anpassen: export KEY_COUNTRY=&#8220;DE&#8220; export KEY_PROVINCE=&#8220;Niedersachsen&#8220; export KEY_CITY=&#8220;Langenhagen&#8220; export KEY_ORG=&#8220;TWSoft&#8220; export KEY_EMAIL=&#8220;mail@email.de&#8220; export KEY_EMAIL=mail@email.de # Der KEY_CN mus EINDEUTIG und EINMALIG sien export KEY_CN=server.email.de export KEY_NAME=server.email.de export KEY_OU=TWSoft export PKCS11_MODULE_PATH=changeme export PKCS11_PIN=1234 In &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/blog.wenzlaff.de\/?p=2073\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eWie kann OpenVPN auf einem WR-703N unter OpenWrt eingerichtet werden?\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[808,695],"tags":[690,2184,752,988,678,694],"class_list":["post-2073","post","type-post","status-publish","format-standard","hentry","category-linux-2","category-tp-wr703n","tag-703n","tag-anleitung","tag-einrichten","tag-openvpn","tag-openwrt","tag-wr-703n"],"_links":{"self":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/2073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2073"}],"version-history":[{"count":0,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/2073\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2073"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}