Transforming Your Raspberry Pi into a Wi-Fi Router with Tor Network

Did you know that you can turn an idle Raspberry Pi at home into a Wi-Fi router connected to the Tor network? In this tutorial, we will show you how to do this step by step.

I first searched the internet for tutorials to set up this Tor router, as I had done one in the past. Unfortunately, the tutorials I found were all outdated, from when Raspberry Pi OS didn’t yet use NetworkManager. After struggling for a while and achieving a satisfactory result, I realized that with a good tutorial, it wouldn’t take more than 10 minutes to set up the router. So, I decided to document this in the form of a blog post, so that people in the future with the same need don’t go through the same trouble I did.


  • Raspberry Pi with Raspberry Pi OS installed.
  • Configured Wi-Fi connection.

Step 1: Setting Up the Access Point

First, let’s configure the Raspberry Pi’s Wi-Fi interface as an access point using Network Manager. Run the following commands in the terminal:

sudo nmcli con add con-name hotspot ifname wlan0 type wifi ssid "TOR-WIFI"
sudo nmcli con modify hotspot wifi-sec.key-mgmt wpa-psk
sudo nmcli con modify hotspot wifi-sec.psk "password123"
sudo nmcli con modify hotspot 802-11-wireless.mode ap bg ipv4.method shared

Make sure to change “password123” to a strong and secure password. This will be the password for your Tor Wi-Fi network.

Step 2: Configuring Tor

Next, let’s configure Tor. First, install Tor using the following command:

sudo apt-get install tor

Then, add the following lines to the /etc/tor/torrc file, replacing the IP address of the Wi-Fi interface if necessary:

Log notice file /var/log/tor/notices.log
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1

Step 3: Setting Up Iptables Rules

Finally, configure the iptables rules to redirect traffic. Run the following commands:

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22
sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040


With these simple steps, you have turned your Raspberry Pi into a Wi-Fi router connected to the Tor network. Now you can browse with more security and privacy. Always remember to regularly update your system and take additional security measures as needed.

For more details and information on this tutorial, check out the sources below:

I hope this tutorial is helpful to you. Let us know in the comments if you have any questions or feedback!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.