VPN Server on Android

Posted by

If you’re not using a VPN, you should consider using one. A Virtual Private Network (VPN) extends a private network across a public network. This gives you an added layer of security and privacy. Imagine if you are sitting at a Starbucks on their free public WiFi. Well, someone could have a program such as Wireshark or any other application open and sniff traffic across the network. Potentially, information such as usernames, passwords and other sensitive data could be exposed. Now let’s say you are using a VPN to connect to your home network while you are at Starbucks. Now, anyone who might be sniffing traffic will only see you connect to the IP address of your home network and not any other sites that you connect to. For more information about VPNs, check out this useful lifehacker article.

Now that you understand what a VPN is, let’s talk about running one on Android. Most tutorials will tell you how to connect to a VPN server from your Android, but not actually how to run one on your Android device. To do this, we will be using the power of Linux along with a automatic OpenVPN installer script. So before we get starting running a VPN Server on Android, make sure that you have Linux installed on your Android device.


What You Will Need:

Step 1: Making Directories

Let’s jump right into this. Launch the Linux chroot on your Android device. I am using Linux Deploy in combination with terminal emulator. The first thing that we need to do is create a new directory in the /dev folder. This is because we need a file called tun. However, tun is located underneath /dev/net. So rather than cariously moving it, we will simply be symlinking it. Type in the following:

cd .../

mkdir /dev/net

ln -s dev/tun /dev/net/tun

The last line symlinks the tun file. So now the OpenVPN program will think the tun file is in the dev directory when it is really in the net directory.

Step 2: Install

To take all the hassle out of setting up OpenVPN, we will be using an automated installer script. Type in the follow:

wget http://git.io/vpn --no-check-certificate -O openvpn-install.sh; chmod +x openvpn-install.sh;

This will begin the installer. From this point everything is self-explanatory. Input your IP address and generate keys for the clients that you want connecting to your VPN server. It will also output a corresponding .ovpn file that we will need to use if we want to connect using OpenVPN from another android device. It will also start the OpenVPN service.

OpenVPN Automated Installer

Step 3: Transferring Keys

Finally, you need to move the generated keys to somewhere that you can access from within Android. Remember, the Linux environment and Android environment don’t share the same folders in your Chroot. One simple way around this is to copy the generated .ovpn file to the /dev folder (that is shared between the Linux environment and Android). Then, from within Android, use root explorer to grab that .ovpn file and move it to somewhere save, like your downloads folder. In any case, make sure you are able to get that .ovpn file so that you can send it to the client that you need.

Step 4: Connecting

OpenVPN Connect Android App

If you want to connect to your OpenVPN server from another Android device, download the OpenVPN connect app. From within the app, import the file that you transferred from the previous step. When you hit connect, it should connect you to the OpenVPN server running on your (other) Android device.