Setting up a Poptop (PPTP) VPN on Ubuntu

This is a pretty useful trick if you need to get around a corporate firewall or the Great fireWall of China. It still allows PPTP through, setting it up is pretty easy and unlike OpenVPN it’s supported by every major OS without any additional software. You can even use it from your iPhone.

To get it going you need one server or VPS that you have access too. Install pptpd with
sudo apt-get install pptpd
Now to edit some files… I’d suggest giving your machine a static IP address by editing /etc/network/interfaces (be careful, if you are not using the server version of Ubuntu Network Manager will most likely take over and set your machine back to DHCP. I’d recommend disabling Network Manager or trying to set a Static IP through it.

You will first need to figure out what subnet your router is using. The quickest way to do this is just to type ifconfig at the command prompt. Look for the output from

eth0, it should look something like this:
eth0 Link encap:Ethernet HWaddr 00:22:22:22:22:22
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::240:45ff:fe26:775a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:225008 errors:0 dropped:0 overruns:0 frame:0
TX packets:76464 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32669088 (32.6 MB) TX bytes:21169594 (21.1 MB)
Interrupt:23 Base address:0xc800

The blue line is the one that you need to pay attention to. To drastically oversimplify, the numbers next to inet addr, are your IP address and the first three represent your subnet. Ok, I’m too lazy to write the rest of this with that much detail. Long story short:

  • set your current IP address with /etc/network/interfaces to a static IP.
  • edit /etc/pptpd.conf and add this:
    localip 192.168.1.101
    remoteip 192.168.1.20-24

    changing the IPs to match your network’s config.
  • Add a line to /etc/ppp/chap-secrets with desired name and password
  • Uncomment and enable the the #net.ipv4.ip_forward=0 line in /etc/sysctl.conf to net.ipv4.ip_forward=1
  • Edit /etc/rc.local and add the following before the exit 0:
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables -A FORWARD -i eth0 -o ppp0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i ppp0 -o eth0 -j ACCEPT
  • Execute /etc/init.d/rc.local start to start the IP masquerading
  • Execute sysctl -p to refresh the sysctl.conf settings you changed
  • That should do it.

    References:
    http://www.sharedknowhow.com/2008/09/linux-vpn-server-installation-for-use-with-iphone/
    http://www.ubuntugeek.com/howto-pptp-vpn-server-with-ubuntu-10-04-lucid-lynx.html

FFmpeg iphone recipes

My Version
This is the ffmpeg command I use with the copy of ffmpeg I built locally on my mac via MacPorts. Check that your ffmpeg is OK by running
ffmpeg
from the command prompt, it will spit out some information about the various options it was compiled with, should look more or less like this:

FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/opt/local --disable-vhook --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64

Then use a command like the one below:

ffmpeg -i INPUT.MOV -acodec libfaac -ab 128k -s 640x480 -vcodec libx264 -vpre hq -vpre ipod640 -b 1500k -aspect 4:3 -threads 0 -f ipod output.m4v

Info taken from this site.
Stolen from Azureus

Azureus now has iPhone encoding built in. I was a little curious how it managed the encoding, I had hoped they wrote a Java based video encoder capable of converting anything into iPhone suitable mp4s thereby creating a cross-platform solution that didn’t require compilation, but alas they, like everybody else used the power of open source via ffmpeg.

A little playing with the ps command and I was able to rescue the ffmpeg incantation they use to convert to iPhone. Since they helpfully include a pre-compliled ffmpeg binary with all the necessary libs this is actually almost as good since as many know trying to compile ffmpeg for each platform can be quite a difficult and trying experience.

Anyhow, here’s the code:

/Users/YourUser/Library/Application Support/Vuze/plugins/vuzexcode/ffmpeg -y -threads 2 -i file.avi -f mp4 -s 480x272 -r 23.976 -vcodec libx264 -bf 0 -coder 0 -refs 4 -g 50 -maxrate 8000kbps -bufsize 8000kbit -crf 20 -me_method umh -ar 32000 -ac 1 -ab 128 -acodec libfaac outfile.mp4

Snow Leopard upgrade difficulties (adventures with Prism and Fluid SSBs)

For whatever reason upgrading to Snow Leopard broke the Fluid webApp I use to monitor my gMail account. (What’s Fluid you ask? Fluid is an application that allows you to make a website into a separate application. Basically, it’s a new browser window, but it gives you a separate icon on your Dock/Start Menu/What have you). I use Fluid with Google Gear’s offline plugin to get the convenience of a standalone email app, but still use the Gmail interface I’m used too and still be guaranteed to have access to all my email anywhere I can find a web browser.

One of the nicest things about using Fluid was that it let me use Google’s Offline Gmail extension (and the Google Gears plugin it requires) separate from my browser. That way I don’t have to clutter up my browser’s profile directory  with all my offline emails (this is important to me since I sync my entire browser profile over Dropbox so that I get the same browsing experience everywhere). Unfortunately, it appears Google’s Gears isn’t quite compatible with Snow Leopard yet, so my offline Gmail functionality is no longer working. Confusingly, Fluid wouldn’t even load the Gmail website, it just hung at a white screen repeatedly.

Until Google updates the Gears plugin to support Snow Leopard, I’m temporarily switching back to Mozilla’s Prism product. Prism is very similar to Fluid (in fact, Prism is what inspired Fluid’s developers to create Fluid), but instead of being based on Apple’s WebKit (and thus highly integrated with OS X) it’s based on the Firefox code. This has the nice advantage that it’s cross platform and that it’s capable of using Firefox add-ons. It turns out only the Gears Safari plugin is broken on Snow Leopard, the Gears firefox add-on still works fine, so Prism has been able to solve all my email woes.

Well, almost all. One nice feature of Fluid is that it automatically shows dock badges on the Gmail dock icon whenever a new email message comes in. With Prism I’m stuck relying on my Gmail Checker Firefox add-on to alert me to new messages. Getting offline Gmail to work in Prism is a bit of a challenge though. I ended up following the directions here:

http://westacular.livejournal.com/43666.html

with some references to the directions here:

http://otaqui.com/blog/382/enable-google-gears-and-offline-gmail-for-mozilla-prism/
Here’s my modified copy of the google-gears xpi, it should work on any version of Prism since I basically just short-circuited the version check. YMMV, I’m not responsible for any computing disasters that may result from using this.