How to Turn a Raspberry Pi into a Tor Routing Node

Turning a Raspberry Pi into an anonymous routing node—often called an onion router or a “Pi-hole” style privacy gateway—allows you to route your network traffic through the Tor network, masking your IP address and encrypting your data. This process transforms a standard Raspberry Pi into a dedicated privacy appliance for your home network. The project involves preparing your hardware, installing a lightweight Linux operating system, configuring the Tor software as a middle or bridge relay, and setting up routing rules to direct your network traffic through the anonymizing network.

Gathering Your Hardware and Software

Before beginning, you need a few essential components to ensure the node runs efficiently and stays online 24/7.

Initial System Setup and Security

Operating a network node requires strict security measures to protect both your device and the traffic passing through it.

  1. Flash the OS: Use the Raspberry Pi Imager to flash Raspberry Pi OS Lite onto your microSD card. During customization, set a unique username and a strong password, and enable SSH access.
  2. Update the System: Insert the card into the Pi, boot it up, connect via SSH, and run the following commands to ensure all software is up to date:
sudo apt update && sudo apt upgrade -y
  1. Configure a Static IP: Edit your network configuration (usually via /etc/dhcpcd.conf or NetworkManager depending on the OS version) to assign a permanent local IP address to your Pi so your router always knows where to find it.

Installing and Configuring Tor

The core of the anonymous routing node relies on the Tor software package daemon, which handles the encryption and relaying of data packages.

  1. Install Tor: Download the daemon and its architectural dependencies directly from the official repositories:
sudo apt install tor tor-geoipdb -y
  1. Edit the Configuration File: Open the main Tor configuration file located at /etc/tor/torrc using a text editor like nano.
  2. Define the Node Role: To configure the Pi as a non-exit relay (which is safest for home networks as it doesn’t expose you to legal risks associated with malicious exit traffic), add the following lines, replacing the placeholder information with your own details:
Nickname MyPiNode
ContactInfo your-email@example.com
ORPort 9001
ExitRelay 0
SocksPort 9050

Network Routing and Firewall Rules

For your node to successfully communicate with the global Tor network and route traffic, you must configure your local network boundaries.

  1. Port Forwarding: Access your home router’s admin panel and forward the ORPort (9001) to the static IP address of your Raspberry Pi. This allows external Tor nodes to establish a connection with your relay.
  2. Configure the Local Firewall: On the Raspberry Pi, set up a firewall using ufw to block unauthorized incoming connections while explicitly permitting Tor traffic and SSH management:
sudo apt install ufw
sudo ufw allow 22/tcp
sudo ufw allow 9001/tcp
sudo ufw enable

Verifying Node Functionality

Once configured, you must verify that the Tor service is running smoothly and that your node is successfully participating in the network.

  1. Restart the Service: Apply your configuration changes by restarting the Tor daemon:
sudo systemctl restart tor
  1. Check the Status Logs: Monitor the live system logs to ensure there are no bootstrap errors or port connectivity complaints:
sudo journalctl -exu tor
  1. Network Lifecycle: It typically takes a few hours for the Tor directory authorities to verify your open ports and begin routing active lifecycle traffic through your new Raspberry Pi node. You can track your node’s public metrics and bandwidth allocation online via the official Tor Metrics website using your assigned nickname.