Stealthy tunnel with stunnel, OpenVPN on Mac OS and Debian
http://www.numberspeaks.com/wp-content/uploads/2017/03/35366000233_9b9768658b_b-300x240.jpg 300w,
http://www.numberspeaks.com/wp-content/uploads/2017/03/35366000233_9b9768658b_b-768x614.jpg 768w" sizes="(max-width: 660px) 100vw, 660px" class="clear extendsBeyondTextColumn" data-reader-unique-id="7" style="max-width: none; margin: 0.5em auto; display: block; height: auto; clear: both; width: 660px; margin-inline-start: -6.953125px;">
OpenVPN is more and less banned in some countries, therefore to be able to use it there, we need to make it stealthy by installing a 3rd party software like Tor, SSH Tunnel or Stunnel which hides openVPN traffic from governmental firewall detection. The principle is quite simple, we create a tunnel between our computer and the openVPN server which is encrypted by a certificate, then we send our openVPN traffic through this tunnel.
Debian 8 stunnel server installation
First OpenVPN should be configured to use TCP instead of UDP, on this example we open port number 1000 and redirect the traffic to localhost port number 443 which is my openVPN server port. We will start by installing the package, run this command to install sTunnel:
1 |
|
Follow the installation wizard and edit /etc/stunnel/stunnel.conf with your favorite editor like bellow:
1 2 3 4 5 6 7 8 |
|
After the installation if there’s no stunnel.pem file, we need to create the certificate by running this following command.
1 2 3 |
|
Start sTunnel
check stunnel.log to make sure there’s no error.
Mac OS X stunnel client installation and configuration
First we need to install homebrew, installation guide is on HomeBrew‘s website. After completing homebrew installation run this command:
Then edit stunnel.conf file, run this command:
1 |
|
1 2 3 4 5 6 |
|
This config file will create a tunnel from localhost on port 1000 to the remote ip 80.247.81.210 on port 1000, change the ip 80.247.81.210 and the port following your current network configuration.
Mac OS X openVPN configuration
I will not describe how to setup the openVPN client, but there’s 2 mandatory modifications to bring to our conf file. Change the remote ip address to localhost with the right port we just set before on sTunnel config file and add those new directives redirect-gateway def1
and route remote_vpn_ip_address 255.255.255.255 net_gateway
that will route all internet traffic to the VPN gateway except the one in destination to our remote vpn ip address.
1 2 3 |
|
Save the modification.
Start sTunnel on Mac OS X
Make sure the sTunnel server is up and running before starting stunnel on the client:
use netstat -an | grep :1000
from command line to check if Stunnel has successfully started, if you have a result, now you should be able to use your new openVPN config file to connect to your openVPN server in stealth mode.