{"id":4019,"date":"2016-08-02T23:55:45","date_gmt":"2016-08-02T21:55:45","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=4019"},"modified":"2016-08-03T15:54:45","modified_gmt":"2016-08-03T13:54:45","slug":"openvpn-create-a-peer-to-peer-network-between-two-clients","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/openvpn-create-a-peer-to-peer-network-between-two-clients\/","title":{"rendered":"OpenVPN: Create a peer to peer Network between two Clients"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_4019 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_4019')){$('.twoclick_social_bookmarks_post_4019').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"OpenVPN%3A%20Create%20a%20peer%20to%20peer%20Network%20between%20two%20Clients\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Afor%20creating%20a%20simple%20peer%20to%20peer%20network%20between%20two%20clients%20you%20do%20not%20have%20to%20setup%20a%20complete%20X.509%20certificate%20based%20infrastructure.%20You%20can%20use%20a%20static%20key%20created%20by%20OpenVPN%20for%20such%20purposes.%0D%0A%0D%0AIn%20a%20Point-To-Point%20environment%20one%20Computer%20acts%20as%20server%20%28vpnmachine1%3A%20192.168.200.1%29%20the%20other%20as%20client%20%28vpnmachine2%3A%20192.168.200.2%29.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/openvpn-create-a-peer-to-peer-network-between-two-clients\\\/\",\"post_id\":4019,\"post_title_referrer_track\":\"OpenVPN%3A+Create+a+peer+to+peer+Network+between+two+Clients\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>for creating a simple peer to peer network between two clients you do not have to setup a complete X.509 certificate based infrastructure. You can use a static key created by OpenVPN for such purposes.<\/p>\n<p>In a Point-To-Point environment one Computer acts as server (vpnmachine1: 192.168.200.1) the other as client (vpnmachine2: 192.168.200.2).<br \/>\n<!--more--><br \/>\nThe steps for Windows. Do the following steps on both machines<\/p>\n<p>Install the latest OpenVPN Version. I assume to the default install path &#8220;C:\\program files\\OpenVPN&#8221;.<\/p>\n<p>Create a config folder for your network and add 2 Firewall rules for in and out coming traffic<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nc:\\&gt; mkdir &quot;C:\\program files\\OpenVPN\\config\\p2p-network&quot;\r\nc:\\&gt; netsh advfirewall firewall add rule name=&quot;OpenVPN&quot; dir=out program=&quot;C:\\program files\\OpenVPN\\bin\\openvpn.exe&quot; protocol=udp localport=1194 profile=any enable=yes action=allow\r\nc:\\&gt; netsh advfirewall firewall add rule name=&quot;OpenVPN&quot; dir=in program=&quot;C:\\program files\\OpenVPN\\bin\\openvpn.exe&quot; protocol=udp localport=1194 profile=any enable=yes action=allow\r\n<\/pre>\n<p>Create the secret key <strong>&#8220;C:\\program files\\OpenVPN\\config\\p2p-network\\p2p-network.key&#8221;<\/strong> at one of the machines (vpnmachine1) and copy it over a secure way (i.e. a AES256 encrypted 7z file. From man page: Encryption method. For 7z format, it can be only AES-256, respectively password protected 7z files are always AES256 encrypted) to vpnmachine2 in the equivalent folder.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nc:\\&gt; &quot;C:\\program files\\OpenVPN\\bin\\openvpn.exe&quot; --genkey --secret &quot;C:\\program files\\OpenVPN\\config\\p2p-network\\p2p-network.key&quot;\r\nc:\\&gt; d:\\tools\\7-Zip\\7z.exe a -t7z D.\\temp\\transport.7z -p -mhe=on &quot;C:\\program files\\OpenVPN\\config\\p2p-network\\p2p-network.key&quot;\r\n<\/pre>\n<figure id=\"attachment_4042\" aria-describedby=\"caption-attachment-4042\" style=\"width: 189px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2016\/08\/7zaes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4042 size-medium\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2016\/08\/7zaes-189x300.png\" alt=\"Properties 7z AES256\" width=\"189\" height=\"300\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2016\/08\/7zaes-189x300.png 189w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2016\/08\/7zaes.png 210w\" sizes=\"auto, (max-width: 189px) 100vw, 189px\" \/><\/a><figcaption id=\"caption-attachment-4042\" class=\"wp-caption-text\">Properties 7z AES256<\/figcaption><\/figure>\n<p>At the server create a config file <strong>&#8220;C:\\program files\\OpenVPN\\config\\p2p-network.ovpn&#8221;<\/strong>:<br \/>\n<code><br \/>\ndev tun<br \/>\nifconfig 192.168.200.1 192.168.200.2<br \/>\nsecret \"C:\\\\program files\\\\OpenVPN\\\\config\\\\p2p-network\\\\p2p-network.key\"<br \/>\n# Compress traffic<br \/>\ncomp-lzo<br \/>\n# These settings ensure that OpenVPN reconnects when the partner changes his IP Address<br \/>\nkeepalive 10 60<br \/>\nping-timer-rem<br \/>\npersist-tun<br \/>\npersist-key<br \/>\n<\/code><br \/>\nStart OpenVPN on Servermachine by OpenVPN GUI or enable the OpenVPN Service to wait for incoming connections.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nc:\\&gt; sc config openvpnservice start= auto\r\nc:\\&gt; sc start openvpnservice\r\n<\/pre>\n<p>See logfile &#8220;C:\\program files\\OpenVPN\\log\\p2p-network.log&#8221; if the service starts correct<br \/>\n<code><br \/>\nTue Aug 02 21:44:23 2016 TAP-WIN32 device [Ethernet] opened: \\\\.\\Global\\{A0393BF3-262F-4195-9C8F-83728407A993}.tap<br \/>\nTue Aug 02 21:44:23 2016 Notified TAP-Windows driver to set a DHCP IP\/netmask of 192.168.200.1\/255.255.255.252 on interface {A0393BF3-262F-4195-9C8F-83728407A993} [DHCP-serv: 192.168.200.2, lease-time: 31536000]<br \/>\nTue Aug 02 21:44:23 2016 Successful ARP Flush on interface [9] {A0393BF3-262F-4195-9C8F-83728407A993}<br \/>\nTue Aug 02 21:44:23 2016 UDPv4 link local (bound): [undef]<br \/>\nTue Aug 02 21:44:23 2016 UDPv4 link remote: [undef]<br \/>\n<\/code><br \/>\nAt the client machine the config <strong>&#8220;C:\\program files\\OpenVPN\\config\\p2p-network.ovpn&#8221;<\/strong> is straightforward expect the <strong>remote<\/strong> directive to define the Hostname or IP Address of the server where the client should connect to and the <strong>&#8220;ifconfig&#8221;<\/strong> option where the IP Addresses are turned in opposition to the server config.<br \/>\n<code><br \/>\nremote vpnmachine1<br \/>\ndev tun<br \/>\nifconfig 192.168.200.2 192.168.200.1<br \/>\nsecret \"C:\\\\program files\\\\OpenVPN\\\\config\\\\p2p-network\\\\p2p-network.key\"<br \/>\n# Compress traffic<br \/>\ncomp-lzo<br \/>\n# These settings ensure that OpenVPN reconnects when the partner changes his IP Address<br \/>\nkeepalive 10 60<br \/>\nping-timer-rem<br \/>\npersist-tun<br \/>\npersist-key<br \/>\n<\/code><\/p>\n<p>To establish a connection use OpenVPN-GUI or start the OpenVPN Service.<\/p>\n<p>Logfile <strong>&#8220;C:\\Program Files\\OpenVPN\\log\\p2p-network.log&#8221;<\/strong> should show something like this:<br \/>\n<code><br \/>\nTue Aug 02 21:47:13 2016 UDPv4 link local (bound): [undef]<br \/>\nTue Aug 02 21:47:13 2016 UDPv4 link remote: [AF_INET]10.254.10.10:1194<br \/>\nTue Aug 02 21:47:13 2016 Peer Connection Initiated with [AF_INET]10.254.10.10:1194<br \/>\nTue Aug 02 21:47:13 2016 <strong>Initialization Sequence Completed<\/strong><br \/>\n<\/code><br \/>\nAnd test the connection <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nC:\\&gt;ping 192.168.200.1 -n 1\r\n\r\nPinging 192.168.200.1 with 32 bytes of data:\r\nReply from 192.168.200.1: bytes=32 time=1ms TTL=128\r\n\r\nC:\\&gt;ping 192.168.200.2 -n 1\r\n\r\nPinging 192.168.200.2 with 32 bytes of data:\r\nReply from 192.168.200.2: bytes=32 time&lt;1ms TTL=128\r\n\r\n<\/pre>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, for creating a simple peer to peer network between two clients you do not have to setup a complete X.509 certificate based infrastructure. You can use a static key created by OpenVPN for such purposes. In a Point-To-Point environment one Computer acts as server (vpnmachine1: 192.168.200.1) the other as client (vpnmachine2: 192.168.200.2).<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[900,573,857,899,898],"class_list":["post-4019","post","type-post","status-publish","format-standard","hentry","category-openvpn","tag-7zip-aes256-encryption","tag-connection","tag-openvpn","tag-peer-to-peer","tag-point-to-point"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/4019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=4019"}],"version-history":[{"count":37,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/4019\/revisions"}],"predecessor-version":[{"id":4049,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/4019\/revisions\/4049"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=4019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=4019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=4019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}