Raspberry Pi as a Tor router and web filter

Lead Image © Daniel Villeneuve, 123RF.com

Personal Protection

With a WiFi stick and a few simple steps, you can turn your Raspberry Pi into a Tor proxy that will route all Internet connections from your home network over the anonymous Tor network.

Twenty years ago, communication changed forever in the western world with the appearance of mobile telephones and the Internet. The leading edge of this industry is currently represented by social networks like Facebook, Google+, and Twitter. The resulting flood of information has given rise to a tendency among government agencies to eaves drop on personal communication, as demonstrated by the programs Tempora and Prism.

However, users are not powerless in the fight to protect the privacy of their data. The Tor network makes it possible to hide your IP address, the most important identifying characteristic when surfing the web, and thereby preserve anonymity. The most elegant way of using Tor is to convert a standard Raspberry Pi into a Wi-Fi network access point that routes all connections over the Tor network.

What Is Tor?

Tor originated at Cambridge University, where it was christened "The Onion Router," because its multi-level approach to packet transfers resembles the layers of an onion. Shortly thereafter, the US Navy Research Laboratory, which had already been working with similar methods, took note of Tor and supported the project. Since December 2006, the non-profit foundation "Tor Project" has been promoting the development of the software.

Figure 1 provides an overview of how Tor functions. At startup, the client requests a list of Tor nodes from a directory server for the Tor network and downloads them. From this list of nodes, the client chooses a so-called "entry guard" for entry into the network. The resulting connection runs over middle and exit nodes to the targeted server; all data remains encrypted as it moves from the client to the Tor exit node.

Neither the exit node nor the target server can identify the originator of the request. Only the entry guard has that information, but it does not know the target server.

Figure 1: Tor uses entry and middle nodes to send the data over an exit node to the target server.

Centralized Instead of Local

As soon as your computer is outfitted with a SOCKS-compliant browser and a Tor proxy, you are ready to conceal its IP address. However, to use Tor throughout your home LAN, you would need to install it on each and every device, including smartphones and tablets. Even then, Tor could only be used with applications that also communicate via SOCKS.

In this type of scenario, operating Tor on one central point in your home network makes more sense. If this point also works as the Wi-Fi access point, using Tor becomes even easier. In that case, you could ten use Tor without any problems on all devices, from smartphones to smart TVs and PCs. Because of its energy efficiency and small physical size, the Raspberry Pi provides a perfect basis for your own Tor router.

Adafruit [1] offers such a Rasp Pi and Tor combination for around US$ 90 under the product name "Onion Pi" (Figure 2). If you want to save money and are not afraid to deal with Linux, you can put together your own Onion Pi one step at a time.

Figure 2: A prebuilt and preconfigured Onion Pi, as offered by Adafruit. (Photo: Adafruit.com)


If you want to build the Onion Pi yourself, the required hardware components include a Raspberry Pi Model B, preferably Rev.2, a Wi-Fi adapter that is compatible with the operating system (Raspbian, in this example), a LAN cable, an SD card with at least 4GB of memory, and a power supply with a micro-USB connector and an output of at least 700 mAh.

Although a housing for the Rasp Pi is not part of the necessary equipment, it does help make the ssystem more living room compatible. If you want to install the OS via your desktop, you will also need an active USB hub. These instructions assume you operate a router with an activated DHCP server, to which the Tor-Rasp Pi later connects.

At this point, you need to decide which operating system you would like to use for the Tor-Rasp Pi. Although the Onion Pi Project recommends Occidentalis [2], as part of its own distribution targeted to those who like to tinker with hardware, I used Raspbian because it is easier for beginners. You should first download the system image onto a computer and extract it there.

Make sure the computer correctly recognizes and attaches the SD card. You can locate the appropriate device identifier via fdisk -l or dmesg. Before you transfer the image, be sure to unmount any potentially mounted partitions on the SD card via sudo umount /dev/<Device>. Then, switch to the directory containing the unpacked image and write the image file to the SD card.

# dd if=/<path>/<to>/<image>/2013-07-26-wheezy-Raspbian.img of=/dev/<target> bs=4M

The output target (of) must be a device (e.g., /dev/sdd) rather than a partition (/dev/sdd1). After the image transfer, you should remove the SD card and insert it into your Rasp Pi. Now you can connect the power supply, the LAN cable, and the Wi-Fi adapter, together with the HDMI cable, to the Raspberry Pi and boot the Raspberry Pi system.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content