This guide steps you through setting up your own obfuscated OpenVPN system.

Note that there is a series of Pluggable Transports have now been packaged specifically for OpenVPN by Operator Foundation. These can be accessed here.


A VPN is an easy to manage service that can help users access content in countries where there is blocking of DNS, ports, IP addresses and protocols.

VPN circumventing a firewall

VPN circumventing a firewall

However, VPNs are increasingly targeted for blocking themselves. Deep Packet Inspection (DPI) is able to block any targeted application or protocol by filtering the traffic and preventing it from passing firewalls to the outside world Internet. As DPI firewalls act based on the packet type, not the port number, simple “tricks” like changing the port will not help

Pluggable transports make it possible to bypass such filtering without modifying the VPN itself but proxying the traffic into obfuscated tunnels which are significantly more difficult to identify and/or are costly to block to enable the traffic to pass through. Read more about different types of obfuscation or the history of filtering.

Obfusctated VPN circumventing a DPI firewall

Obfuscated VPN circumventing a DPI firewall

In this process, we will be using shapeshifter-dispatcher which is a command line proxy tool which will act as a PT to help OpenVPN proxy the traffic through the firewall:

“The Shapeshifter project provides network protocol shapeshifting technology (also sometimes referred to as obfuscation). The purpose of this technology is to change the characteristics of network traffic so that it is not identified and subsequently blocked by network filtering devices.”

This tutorial uses Dispatcher to enable OpenVPN traffic to pass DPI firewalls, but it is important to note that this concept and process can apply to other services, including but not limited to VOIP and SSH or any other UDP or TCP connection.

If you already have OpenVPN installed and running on a server, you can skip forward to installing Dispatcher


First, we will be installing the following packages that you will use during the installation

  • Openssl, in case it was not installed, this will allow you to generate ssl certificate for the server and the clients
  • ca-certificates, the common CA certificates
  • git, distributed version control system, we will need it to setup shapeshifter-dispatcher
  • curl, to get files from web or ftp server.
  • screen, this application will help you to run processes in the background
  • easy-rsa, required for creating certificates
apt-get update
apt-get install openssl ca-certificates git curl screen easy-rsa -y

Installing OpenVPN

In this step, we will install and configure OpenVPN Server on Ubuntu 16.04.1 LTS and test it in non-DPI environment to be sure that it’s working. Please note that the procedure will probably work on any Debian / Ubuntu distro. You must run the installation and configure the different applications as root or sudoers account.

apt-get install openvpn 

Install and configure Certificates

In this step, you will create the PKI, setup the CA, DH parameters, the server and client certificates.

  • Create CA directory:
make-cadir ~/openvpn-ca
cd ~/openvpn-ca
  • You need to change the vars of the configuration you will generate, run the following commands and change the values:
nano vars
  • change the following values to what you want it to be:
export KEY_CITY="SanFrancisco"
export KEY_ORG="Fort-Funston"
export KEY_EMAIL="[email protected]"
export KEY_OU="MyOrganizationalUnit"
export KEY_NAME="server"
  • then run the following command to use the vars:
source vars
  • Run the following command to remove all the old keys
  • Now generate your CA root certificate
  • Now generate your server key file
./build-key-server server

After you finish the process, it will ask you to verify the expiration day of the certificate and the permission to issue the certificate, answer (Y) to both requests.

  • Now generate Diffie-Hellman keys
  • Now generate your TLS integrity verification capabilities, which will improve the security of the server and prevent any denial-of-service attempts
openvpn --genkey --secret keys/ta.key
  • Move the files we need to OpenVPN main folder:
cd keys/
cp ca.crt ca.key server.crt server.key ta.key dh2048.pem /etc/openvpn/
  • Create the server.conf file:
nano /etc/openvpn/server.conf
  • Add the following configurations to it
mode server
port 1194 #Change the port of OpenVPN to the one you want
proto tcp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
tls-auth ta.key 0
topology subnet
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
  • You can change the DNS you will be using to anyone you want
push "dhcp-option DNS"
push "dhcp-option DNS"
keepalive 10 120
cipher AES-256-CBC
status openvpn-status.log
verb 3

Configure the network

In this step, you will configure your network to allow OpenVPN traffic. You will need to change the following values to the correct numbers:

  • YOURSERVERIPADDRESS: The Public IP address of your server
  • OPENVPNPORT: The port you will use for the OpenVPN Server
  • OBFSPORT: The port you will use for shapeshifter-dispatcher

Allow IP forward, most of the Linux distributions will have IP Forwarding disabled for security reasons, but we will need to allow IP forward in order to allow the OpenVPN to function. By running the following command, we will check if IP Forwarding is enabled:

sysctl net.ipv4.ip_forward

if the value was 0:

net.ipv4.ip_forward = 0

that means IP forward is disabled, to enable it run the following command:

echo 1 > /proc/sys/net/ipv4/ip_forward

Set NAT for the VPN subnet:

iptables -I INPUT -p tcp --dport OPENVPNPORT -j ACCEPT
iptables -I FORWARD -s -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

Start the OpenVPN service

/etc/init.d/openvpn restart
systemctl start [email protected]
  • Now check if OpenVPN is running by checking if the tun0 interface is available
ip addr show tun0
  • if you see a configured interface (Assigned IP address to tun) run the following command to enable OpenVPN:
systemctl enable [email protected]
  • Add a client:

In this step, you will create the key, certificate and configuration files for your first OpenVPN user. The configuration file will have the client certificate embedded.

cd ~/openvpn-ca/
source ./vars
  • Create a key file named CLIENT
./pkitool CLIENT
  • This process will generate CLIENT.key and CLIENT.crt, move them to OpenVPN folder
cd keys/
cp CLIENT.key CLIENT.crt /etc/openvpn
  • Create the client configuration file:
nano CLIENT.ovpn
  • Then add the following configurations to the file:
dev tun
proto tcp
sndbuf 0
rcvbuf 0
remote YOURSERVERIPADDRESS #Change this one to your public IP address
port 1194 #Change this one to the port you’re using for OpenVPN
resolv-retry infinite
remote-cert-tls server
cipher AES-256-CBC
setenv opt block-outside-dns
key-direction 1
verb 3
tls-auth ta.key 1
ca ca.crt
cert CLIENT.crt
key CLIENT.key

Save the file, name it CLIENT.ovpn and put it it along with the following files ,CLIENT.crt, CLIENT.key, ta.key and ca.crt and test the OpenVPN connection.

If it worked – continue to the installation of shapeshifter-dispatcher and enable obfuscation for OpenVPN.

Server Obfuscation Configuration

In this step, we will install and use Shapeshifter-dispatcher Server and client on Ubuntu 16.04.1 LTS. Please note that the procedure will probably work on any Debian & Ubuntu distro. You must run the the process as root or sudoers account.

The installation process of Shapeshifter-dispatcher is the same on the server and client, so apply these steps on both.

Install and configure shapeshifter-dispatcher

Prerequisite: You will need to install Go

curl -LO
tar -C /usr/local -xzf go1.11.2.linux-386.tar.gz

The next step is to set up the Go environment, adding it to your profile with the command:

nano ~/.profile

You should these lines to the end of the file:

export GOPATH=~/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Use Ctrl-X to exit the editor, and answer Y to save the file. To create the path for Go to store its files and make the new paths effective immediately, run the commands:

mkdir ~/go
source ~/.profile

We set the value of GOPATH to ~/go. This means that Go will put its source code into ~/go/src and compiled programs into ~/go/bin.

Now you can download and compile Shapeshifter, along with its dependencies:

go get -u

Shapeshifter-dispatcher server and client setup:

Run shapeshifter-dispatcher on the server by running the following command for Obfs2:

screen ~/go/bin/shapeshifter-dispatcher -server -transparent -ptversion 2 -transports obfs2 -state state -bindaddr obfs2-YOURSERVERIPADDRESS:OBFSPORT -orport

You will get this screen. Don’t forget to change the IP address and ports within the command.

Server Setup results screenshot Server Setup results screenshot

And the following command to use Obfs4:

screen ~/go/bin/shapeshifter-dispatcher -transparent -server -state state -orport -transports obfs4 -bindaddr obfs4 -bindaddr obfs4-YOURSERVERIPADDRESS:OBFSPORT -logLevel DEBUG -enableLogging -extorport

When the server is running for the first time, it will generate a new public key and it will write it to a file in the state directory called obfs4_bridgeline.txt. This information is needed by the dispatcher client. Look in the file and retrieve the public key from the bridge line. It will look similar to this:

Bridge obfs4 <IP ADDRESS>:<PORT> <FINGERPRINT> cert=OfQAPDamjsRO90fDGlnZR5RNG659FZqUKUwxUHcaK7jIbERvNU8+EVF6rmdlvS69jVYrKw iat-mode=0

Set NAT for shapeshifter-dispatcher on the server:

iptables -I INPUT -p tcp --dport OBFSPORT -j ACCEPT

Run shapeshifter-dispatcher on the client side for Obfs2:

screen ~/go/bin/shapeshifter-dispatcher -client -transparent -ptversion 2
    -transports obfs2 -state state -target YOURSERVERIPADDRESS:OBFSPORT

You will get this screen:

screenshot of launching ptclientproxy, success at listening stage

Or the following command to use Obfs4, don’t forget to change the value of ‘cert’ with the one you generated on the server:

screen ~/go/bin/shapeshifter-dispatcher -transparent -client -state state -target YOURSERVERIPADDRESS:OBFSPORT -transports obfs4 -options "{\"cert\": \"OfQAPDamjsRO90fDGlnZR5RNG659FZqUKUwxUHcaK7jIbERvNU8+EVF6rmdlvS69jVYrKw\", \"iatMode\": \"0\"}" -logLevel DEBUG -enableLogging

For more information on how to use Obfs4, check the offical guide of Shapeshifter-Dispatcher

Client Obfuscation Configuration

After running both the server and the client side, shapeshifter-dispatcher will connect and handshake which will then establish the connection between both sides.

Now you will be able to reconfigure the client’s OpenVPN configuration file to send OpenVPN requests and packets to the client shapeshifter-dispatcher which will then establish the obfuscated connection with shapeshifter-dispatcher server which will receive the obfuscated packets and forward the OpenVPN client connection to the OpenVPN Server.

Shapeshifter-dispatcher uses the port 1234 on the client side by default which means that this is the port which OpenVPN will talk to on the client machine.

You need to open the file CLIENT.ovpn and change the following values to point the VPN client at the local Shapeshifter-dispatcher for obfuscation and routing:

port 1234

Save the file and establish the connection, you’re now off the radar!

Note: We used obfs2 in this example to explain how Pluggable Transports can be used with OpenVPN only, Obfs2 is censored in many places and you might use other transports like Obfs4 – Learn how to use it!