|
|
(16 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | ==Introduction==
| |
| | | |
− | <b>Stunnel</b> is an open-source proxy service that adds TLS encryption to clients and servers already existing on a VPN network. TLS encryption provided by Stunnel can be used as an additional layer of encryption for data sent by OpenVPN. This procedure increases the security of the established connection and provides higher chances of passing a Deep packet inspection (DPI) check.
| |
− |
| |
− | This article contains instructions on how to configure an OpenVPN over the Stunnel topology.
| |
− |
| |
− | ==Overview==
| |
− |
| |
− | <b>You will need</b>
| |
− |
| |
− | <ul>
| |
− | <li>two routers of the RUTxxx series (except RUT850);</li>
| |
− | <li>at least one router (server) with a public IP;</li>
| |
− | <li>TLS certificates for the server and the client (<i>for instructions on generating TLS certificates, [[How to generate TLS certificates (Windows)?|click here]]</i>).</li>
| |
− | </ul>
| |
− | ----
| |
− | <b>Topology</b>
| |
− |
| |
− | [[File:Networking_device_vpn_stunnel_working_scheme_v4.png]]
| |
− |
| |
− | ----
| |
− | <b>Explanation</b>
| |
− |
| |
− | An OpenVPN client is connected to an OpenVPN server (both hosted on RUT routers) via a TLS encrypted Stunnel connection. This allows the transfer of data between remote private networks (LAN A and LAN B) and adds a TLS security layer for the connection.
| |
− |
| |
− | ==Server configuration==
| |
− |
| |
− | First, configure the OpenVPN and Stunnel servers. The Stunnel server will listen for incoming client connections on the specified TCP port (<i>9999</i> in this example) and connect them to the OpenVPN server running on the local host.
| |
− |
| |
− | The logic of the connection can be visualized like this:
| |
− |
| |
− | [[File:Networking_device_vpn_stunnel_server_working_scheme_v2.png]]
| |
− |
| |
− | ===OpenVPN server===
| |
− | ----
| |
− | Navigate to the <b>Services → VPN → OpenVPN</b> page. Select <i>Role: Server</i>, enter a custom name and click the 'Add New' button. An OpenVPN server instance with the given name will appear in the "OpenVPN Configuration" list. To begin configuration, click the 'Edit' button next to the server instance.
| |
− |
| |
− | The figure below displays the configuration used for our example. Take note of the comments that are provided next to fields that differ from the default value:
| |
− |
| |
− | [[File:Networking_rutxxx_configuration_examples_openvpn_over_stunnel_openvpn_server_configuration_v3.jpg|border|class=tlt-border]]
| |
− |
| |
− | Don't forget to click the <b>Save</b> button located at the bottom-right side of the page.
| |
− |
| |
− | ===Stunnel server===
| |
− | ----
| |
− | Navigate to the <b>Services → VPN → Stunnel</b> page and enable the "Stunnel Globals" configuration:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples stunnel global enabled v1.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | Click <b>Save</b>.
| |
− | ----
| |
− | To create a new Stunnel instance, enter a custom name for it and click the 'Add' button. A new instance with the given name will appear in the "Stunnel Configuration" list. To begin configuration, click the 'Edit' button next to the instance.
| |
− |
| |
− | The figure below displays the configuration used for our example. Take note of the comments that are provided next to fields that differ from the default value:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples stunnel server settings v1.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | Don't forget to click the <b>Save</b> button located at the bottom-right side of the page.
| |
− |
| |
− | ===Open Stunnel port===
| |
− | ----
| |
− | The OpenVPN default port (<i>1194</i>) is opened by default. But you will have manually open the select Stunnel port (<i>9999</i> in this example).
| |
− |
| |
− | To do this, navigate to the <b>Network → Firewall → Traffic Rules</b> page and scroll down until you see the <b>Open Ports On Router</b> section. Fill out the configuration fields as indicated in the figure above and click the 'Add' button:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples openvpn over stunnel firewall configuration v2.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | ==Client configuration==
| |
− |
| |
− | Configure the OpenVPN and Stunnel clients that will be connecting to the server. Unlike in the server, there is a reason to configure the Stunnel client before the OpenVPN client (the other way around will also work but an OpenVPN service restart may be required) so it is recommended to start with that.
| |
− |
| |
− | The OpenVPN client will connect to <i>TCP port 1194</i> of the local host and the Stunnel client will connect to the WAN IP and Stunnel port (<i>192.168.10.1:9999</i> in this example) of the server router.
| |
− |
| |
− | The logic of the entire connection can be visualized like this:
| |
− |
| |
− | [[File:Networking_device_vpn_stunnel_complete_configuration_scheme_v2.png]]
| |
− |
| |
− | ===Stunnel client===
| |
− | ----
| |
− | Navigate to the <b>Services → VPN → Stunnel</b> page and enable the "Stunnel Globals" configuration:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples stunnel global enabled v1.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | Click <b>Save</b>.
| |
− | ----
| |
− | To create a new Stunnel instance, enter a custom name for it and click the 'Add' button. A new instance with the given name will appear in the "Stunnel Configuration" list. To begin configuration, click the 'Edit' button next to the instance.
| |
− |
| |
− | The figure below displays the configuration used for our example. Take note of the comments that are provided next to fields that differ from the default value:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples openvpn over stunnel stunnel client configuration v2.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | Don't forget to click the <b>Save</b> button located at the bottom-right side of the page.
| |
− |
| |
− | ===OpenVPN client===
| |
− | ----
| |
− | Navigate to the <b>Services → VPN → OpenVPN</b> page. Select <i>Role: Server</i>, enter a custom name and click the 'Add New' button. An OpenVPN client instance with the given name will appear in the "OpenVPN Configuration" list. To begin configuration, click the 'Edit' button next to the client instance.
| |
− |
| |
− | The figure below displays the configuration used for our example. Take note of the comments that are provided next to fields that differ from the default value:
| |
− |
| |
− | [[File:Networking rutxxx configuration examples openvpn over stunnel openvpn client configuration v2.jpg|border|class=tlt-border|1100px]]
| |
− |
| |
− | Don't forget to click the <b>Save</b> button located at the bottom-right side of the page.
| |
− |
| |
− | ==Testing and troubleshooting==
| |
− |
| |
− | If you have completed the steps presented above, your configuration is complete. This section provides tips on how to test and troubleshoot this <i>OpenVPN over Stunnel</i> connection.
| |
− |
| |
− | <ul>
| |
− | <li>Check whether remote side is reachable by sending ICMP requests. To do that, go to the <b>Services → CLI</b> page. Login (username: <i>root</i>; password: <i>router's password</i>) and ping the opposite instance:
| |
− | <pre>ping 10.8.0.6</pre>Is the response looks like this, then the connection was established successfully:
| |
− | <pre>
| |
− | 64 bytes from 10.8.0.6: seq=0 ttl=64 time=101.214 ms
| |
− | 64 bytes from 10.8.0.6: seq=1 ttl=64 time=91.018 ms
| |
− | 64 bytes from 10.8.0.6: seq=2 ttl=64 time=88.974 ms
| |
− | 64 bytes from 10.8.0.6: seq=3 ttl=64 time=502.781 ms
| |
− | </pre>
| |
− | </li>
| |
− | ----
| |
− | <li>If there is no response to the ping requests, check whether Stunnel and OpenVPN services are running on the device. For Stunnel use this command:
| |
− | <pre>ps | grep stunnel | grep -v grep</pre>The output should look similar to this:
| |
− | <pre>
| |
− | 16122 root 2992 S /usr/bin/stunnel /tmp/stunnel.conf
| |
− | </pre>For OpenVPN use this command:
| |
− | <pre>ps | grep openvpn | grep -v grep</pre>The output should look similar to this:
| |
− | <pre>13034 root 3428 S /usr/sbin/openvpn --syslog openvpn(7365727665725F41)</pre>
| |
− | </li>
| |
− | ----
| |
− | <li>To restart OpenVPN or Stunnel services, use one of these commands:
| |
− | <pre>/etc/init.d/openvpn restart</pre>
| |
− | <pre>/etc/init.d/stunnel restart</pre>
| |
− | </li>
| |
− | ----
| |
− | <li> Double-check your configuration. Check for configuration mistakes, see if correct certificate files are uploaded onto each instance, make sure the Stunnel port is not used by another program, etc.</li>
| |
− | </ul>
| |
− | [[Category:VPN]]
| |