[Android Software Development] lamaz:
How I got OpenVPN working on FRF91

After many hours I can finally surf using openVPN. Just wanted to spare anybody else the pain. Your mileage may vary. As usual, I am not responsible if you brick your phone.

My configuration uses TAP interface vs. TUN. I want to push ALL traffic through my VPN. The phone will essentially be connected to your internal network.

I assume you already have some knowledge of OpenVPN and have already suffered at least 1 successful client/server connection. Else, get something working on a laptop first, visit the HOW-TO.

Requirements:

OpenVPN-Settings-0.4.6.apk (http://code.google.com/p/android-openvpn-settings/downloads/list)

OpenVPN 2.1.1 statically linked against patched openssl (http://github.com/fries/android-external-openvpn/downloads)

Rooted FRF91 using MoDaCo's Kernel 2.6.32.9-27227-g3c98b0d (http://xdaforums.com/showthread.php?t=702191)

Working version of tun.ko for your kernel (http://xdaforums.com/showpost.php?p=7047385&postcount=46)

Problem:

OpenVPN binaries included in rom don't seem to work. It can't find ifconfig and/or route. When you run the command line you get

Sat Jul 3 13:30:58 2010 Options error: Unrecognized option or missing parameter(s) in [PUSH-OPTIONS]:4: route (2.1.1)
Sat Jul 3 13:30:58 2010 Options error: Unrecognized option or missing parameter(s) in [PUSH-OPTIONS]:7: ifconfig (2.1.1)

Summary:

Install new OpenVPN binaries, install/configure OpenVPN-Settings, add symbolic links to allow openvpn binaries to call ifconfig and route, remove an un-needed route.

Implementation:

1. Unzip/copy openvpn-static-2.1.1 and tun.ko to files to device. (I renamed mine /system/xbin/openvpn)

adb remount
adb push openvpn /sdcard/xbin/
adb push tun.ko /system/lib/modules/
adb reboot

2. Make folder /system/xbin/bb

adb remount
adb shell mkdir /system/xbin/bb

3. Make symbolic links to ifconfig and route

adb shell ln -s /system/xbin/ifconfig /system/xbin/bb/ifconfig
adb shell ln -s /system/xbin/route /system/xbin/bb/route

4. Create a simple script to delete router. Example (/sdcard/openvpn/up.sh)

#!/system/bin/sh
/system/xbin/route del YOUR_VPN_INTERNET_IPADDRESS

5. Make the file executable.

adb shell chmod +x /sdcard/openvpn/up.sh

6. Modify your openvpn.conf to call script after routing, or pass it in as a command line argument. I did the modification to script file.

#remember that I use tap, I don't know about tun
dev tap
route-up "/system/bin/sh /sdcard/openvpn/up.sh"

7. Install/Configure OpenVPN-Settings-0.4.6.apk.

7.0 Install OpenVPN-Settings-0.4.6.apk. Market or

adb install OpenVPN-Settings-0.4.6.apk

7.1 On device, launch OpenVPN Settings.

7.2 Long press openvpn.conf, Preferences.

7.3 Check "Use VPN DNS Server"

7.4 Enter your VPN DNS Server

7.5 Script Security Level Select Built-in + scripts

7.5 press back

7.6 Click click the sub-menu option select Advanced

7.7 Load tun kernel module and make it 'insmod /system/lib/modules/tun.ko' before starting openvpn.

7.8 Change path to openvpn binary to /system/xbin/openvpn

Enjoy!

-LamaZ

Links:

Idea about deleting route entries courtesy of:

Fnorder http://xdaforums.com/showpost.php?p=3395349&postcount=25

http://code.google.com/p/android-openvpn-installer/issues/detail?id=2