Home > sysadmin > Openvpn for android (lollipop) using a static key

Openvpn for android (lollipop) using a static key

The simplest openvpn setup uses a static key. I am using Linode to host my Debian linux server.
I have openvpn running on my linode server with this configuration. Just apt-get install openvpn and
created this tun1.conf in the /etc/openvpn folder.
dev tun1
port 1192
proto udp
# ifconfig
secret /etc/openvpn/static.key
keepalive 10 60

Note the secret line. This is a static key (which you can name anything) generated by this command:
openvpn –genkey –secret static.key

Install openvpn on your android phone (I have it on the 2nd generation Motorola X running Lollipop). Be sure and install the stock openvpn application found in the Google Play Store (https://play.google.com/store/apps/details?id=net.openvpn.openvpn)

After installing, open the app and create a new profile by clicking the + sign.
1) Give your profile a name ie myvpn
2) Check LZO compression
3) With the dropdown menu select static keys.

Proceed to the server tab
1) Add your server (myserver.com)
2) UDP protocol and port 1192 (or whatever port you want. 1192 is the default).

Proceed to the IP and DNS tab
1) add your IPv4 Address
2) add seacrhDomain google.com (the google dns servers should already be listed and

Proceed to the routing tab and add your custom route if you only want to be able to use the vpn
to contact your server. If you want to use the vpn for all your phone traffic, then see last paragraph.

Custom Routes (not necessary..see port forwarding on server)

Proceed to the AUTHENTICATION/ENCRYPTION tab and add
TLS Auth File (You should download the static.key file you created on the server to your android
phone. You can copy it to google drive or dropbox and then store it on your phone under internal storage.

That’s it. Start openvpn on your linode (service start openvpn). Open the adroid app and click the profile
to start the phone client. It should connect in a few seconds to your server and show an icon on the
top tray.

TO forward all your data through your linode, add this firewall script (modify to your system parms)
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i tun1 -j ACCEPT

Categories: sysadmin
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: