OpenVPN with Root - Updated 8/19

fang0654

Member
Mar 18, 2008
17
0
0
Easy way - OpenVPN on rooted/S_OFF Incredible with BusyBox installed:

This is by far the easiest way to set up OpenVPN. Make sure you copy your config file and any relevant keys to a folder on your sdcard. First, you need to know where BusyBox is installed, and if you already have the tun.ko module. For BusyBox, for most Roms based off the 2.2 8/1 leak, the location is /system/xbin. An easy way to check on your phone:

adb shell
find / -iname "iptunnel"

The path containing the file is where BusyBox is installed. If you don't have it installed, you can follow the instructions at the bottom of this post to install it.

The tun.ko module depends on your kernel. With the hydra 2.2 kernels, the location is /system/lib/modules/tun.ko . Easy way to check:

adb shell
find / -iname "tun.ko"

If you do not have tun.ko on your system, then you can download it for 2.2 (tun.zip) or 2.1 (inside openvpn.zip) attached to this post.

Next, download the following two apps from the Android Market:


OpenVPN Installer
OpenVPN Settings


Next, run OpenVPN installer, click install, give it an install path (I prefer /system/xbin), and give it the path to BusyBox.

Finally, run OpenVPN Settings. Go to Menu -> Advanced, make sure "Load tun kernel module" is checked.

Click on "TUN module settings"
Change "Load module using" to insmod
Change "Path to tun module" to... the path to your tun.ko file. Click back.
Update "Path to configurations" and "Path to openvpn binary".

That should be it!


This is how to run OpenVPN on a rooted Incredible using unrEVOked root and the stock 2.1 ROM with S_ON

NOTE: This is only for rooted Stock 2.1 without S_OFF. If you have S_OFF via unrevoked forever, just use Openvpn Installer and Openvpn Settings, both available in the market. Much easier!


This is my first time doing something like this, so bear with me if it is a little rough!

You must have root access to set this up. You do NOT need to go back into recovery adb though.

First, download the attached openvpn.zip containing the following:


tun.ko - kernel module for 2.1.
openvpn-static - statically compiled openvpn

If you are using 2.2, tun.zip contains the module compiled for the 2.2 kernel (thanks Apalyan!)

You will already need to have a working client.conf, and any associated keys. Copy the following files into a folder named 'openvpn' on the sdcard, or push with the following:

adb mkdir /sdcard/openvpn
adb push tun.ko /sdcard/openvpn/tun.ko
adb push client.conf /sdcard/openvpn/client.conf
adb push client.key /sdcard/openvpn/client.key
adb push client.crt /sdcard/openvpn/client.crt
adb push ca.crt /sdcard/openvpn/ca.crt
adb push openvpn-static /sdcard/openvpn/openvpn-static

The following must be done in a root shell:

adb shell
su
mkdir /data/openvpn
dd if=/sdcard/openvpn/openvpn-static of=/data/openvpn/openvpn
chmod 700 /data/openvpn/openvpn

Use the OpenVPN Settings configuration below to start/stop openvpn.

Note: All of the code was already written and ported to Android by the guys behind OpenVPN Settings. I just compiled a new tun.ko from the Incredible kernel source, and recompiled the statically linked openvpn with updated paths to ifconfig and route.

ADDED (thanks wraithdu!):

If you have trouble with post-connection routing, you may need to install busybox for a more powerful route/ipconfig. Instructions are here:

---
busybox is installed by the latest rooting process, but it's not a full install, ie it does not create all the command links. I got the file from the Titanium Backup site:

http://www.matrixrewriter.com/android/files/busybox-1.15.3.zip

To install:

1) extract and push busybox to your sdcard, reboot into recovery
2) mount /system
3) if you don't have /system/xbin (you should), create it
adb shell:
# mkdir /system/xbin (if necessary)
dd if=/sdcard/busybox of=/system/xbin/busybox
cd /system/xbin
chmod 755 busybox
./busybox --install .
4) reboot and done

OPTIONAL - before rebooting replace the busybox installed by the root process in /system/bin
1) mv /system/bin/busybox /system/bin/busybox.bak
2) cp /system/xbin/busybox /system/bin/busybox
 

Attachments

Last edited:

fang0654

Member
Mar 18, 2008
17
0
0
OpenVPN Settings Instructions

OpenVPN Settings v. 4.6 works flawlessly with this! Here are setup instructions:

Install OpenVPN Settings v. 4.6 from:

Can't post links yet, do a google search for OpenVPN Settings, go to the Google Code download page, and download version 4.6.

Then, launch OpenVPN Settings, press Menu -> Advanced, and fill in the following settings:

Load tun kernel module - Checked

TUN module settings:
Load module using - insmod
Path to tun module - /sdcard/openvpn/tun.ko

Path to configurations - leave default

Path to openvpn binary - /data/openvpn/openvpn

It should work beautifully then.
 
Last edited:

dkhait

Member
Jan 26, 2009
47
1
0
ifconfig error

i got it all installed , it connects, but then in the end it says fatal error, ifconfig failed, could not execute external program. any ideas
 

fang0654

Member
Mar 18, 2008
17
0
0
You can run it manually to see what exactly is happening. Try the following:

adb shell
su
/data/openvpn/openvpn --config /sdcard/openvpn/client.conf

What generates the error?
 

dkhait

Member
Jan 26, 2009
47
1
0
error

Wed Jun 16 08:52:50 2010 /system/xbin/bb/ifconfig tap0 192.168.200.2 netmask 255
.255.255.0 mtu 1500 broadcast 192.168.200.255
Wed Jun 16 08:52:50 2010 Linux ifconfig failed: could not execute external progr
am
Wed Jun 16 08:52:50 2010 Exiting


and ifconfig is under /system/bin not /system/xbin/bb/. do you guys know where i need to change that?
 

johnnybags

Senior Member
May 28, 2010
72
3
0
Fang - Thanks again. Do you have any suggestions on a util or tutorial on making a conf file? I've access to our Cisco ASDM for our ASA, the URL for the ASA, group name, Group key, and of course my username and pw.
 

fang0654

Member
Mar 18, 2008
17
0
0
For that, you need vpnc instead of openvpn.

I know the problem with using the VPN Connections app is that the tun.ko autoload doesn't work. There are a couple of things you may be able to do as a workaround.

1. Load the module by hand:

adb shell
su
insmod /sdcard/openvpn/tun.ko

or 2. Use the OpenVPN Settings app from above to load the tun module (just start openvpn, then stop it), then try out the VPNC app.

I don't have a Cisco vpn so I don't have any way of testing whether this works.
 

mattwood2000

Senior Member
May 4, 2010
254
14
48
If your running Linux, just type "adb shell" in you terminal window - make sure your phone is connected via USB cable - you should get the "$" after this command and then your in your phone's shell.

I believe windows is the same way, but I only have Linux stuff running now...
 

PokerMunkee

Senior Member
Jun 18, 2010
55
1
0
If your running Linux, just type "adb shell" in you terminal window - make sure your phone is connected via USB cable - you should get the "$" after this command and then your in your phone's shell.

I believe windows is the same way, but I only have Linux stuff running now...
With the phone connected via USB (Disk drive or anything), I type "adb shell" and get device not found. I'm running Windows 7. Phone has been rooted (have Wifi Tethering installed). Just having issues getting it back to the shell command like when I first rooted it :/
 
Last edited:

PokerMunkee

Senior Member
Jun 18, 2010
55
1
0
OK, had a misspell in the tun.ko file.

I'm connected now. But unable to connect to anything on my network. Still looking into it.

Any ideas? I've restarted the phone. I'm connected to my OpenVPN server. I cannot ping the IP assigned to it (from OpenVPN status page). I cannot ping anything on my internal network from the shell. Shows no data moving. Do I need to do something?

I did a netconf and i have this:

tap0 UP 172.30.100.255 255.255.0.0 0x00001043
 
Last edited:
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone