Nov 24, 2015

Raspberry Pi 2 : Getting started

Not having played around with Linux for a long time, I finally decided to set up a Raspberry Pi 2 project. For $35, this tiny computer does pack a punch. This spec sheet details out everything. You can basically set up a small web, mail, or home automation server and more.

My idea was to turn it into a VPN gateway that sits between my TV and home router and serve up a US IP through OpenVPN. This will basically let me stream Netflix or Hulu directly on the TV, without the need of Miracast or DLNA devices/software.

Having dabbled with OpenVPN and basic routing when setting up my VPS, this was fairly straightforward. I was inspired by this Makezine guide, which used two Wifi dongles - one for connecting to the local network and the other for hosting the VPN access point. Picking the correct dongles is also important; it would need to support the soft AP function. I used an Edimax EW-7811 Un and a Tenda W311MI. Both are fairly cheap and robust, although the Edimax one seems to drop a lot of packets.

In addition to stock Raspbian (a Debian-based distro, optimized for Raspberry Pi), you would also need to install hostapd which will turn the dongle into an AP and also dnsmasq for basic DHCP and DNS for clients connecting to the AP. Once done, you would need to use iptables to do the routing, which basically takes the traffic from the wifi subnet and forwards it to the VPN tunnel. Any client connecting to the AP will have a public IP address of the VPN server.

Performance in terms of VPN throughput remains a concern. My Android phone, connected to the VPN directly, gives 18 Mbps down, whereas the Raspberry AP only gives 3 Mbps. Many discussions suggest this could be due to a bottleneck, as the Ethernet and USB ports share the same interface and the traffic has to traverse the bus twice. Switching the inbound interface from USB to Ethernet didn't improve the situation either; some commenters also suggest that the CPU itself could be a problem. However, 'top' didn't reveal much load on the CPU.

3 Mbps is barely enough to provide a SD stream, so HD is pretty much impossible. Still needs some digging around to identify where the bottleneck is. Even so, I would consider this project a 'fruit'ful one.

With the case open

Up and running