How to construct TOR proxy router with a Raspberry Pi


Raspberry Pi – How to construct TOR proxy router with a Raspberry Pi

Raspberry Pi is a flabbergasting single PC board that can do a lot of tasks, for instance, it can be used as Raspberry Pi proxy ham, your own Pi phone, a VPN that will be your personal, a home automation and so forth. This compact machine can be used to build your individual TOR proxy and incognito you can browse.

Ample of people are unknown with TOR which can be used by any of the individual to use internet with ease and privacy. Your Data can be encrypted with TOR networks into ample layers and the source of the origin of the webpage request gets hidden.  On any of the machine TOR can be run.

Raspberry Pi: Material Required

  • A Raspberry Pi model.
  • Wi-Fi adapter.
  • An SD card which should be greater or equal to 4 GB.
  • For your power supply you need a power supply.
  • An Ethernet cable.
  • Case for your Raspberry Pi.
  • An SD card reader.
  • Power supply for your Raspberry Pi.

raspberry pi onion pi mini

Raspberry Pi – Preparation:

Before starting this we believe that you have setup your Raspberry Pi

Please follow these tutorials in order to

Onto your SD card install an Operating System:

You can skip this step if you have already got an SD card which is Wheezy pre-burned.

Configure your Raspberry Pi after booting it.

For the “Pi” account, change the default password.

Be certain to get bigger the file system to the complete disk, otherwise you will not have enough space.


Raspberry Pi – Ethernet and Wi-Fi connection is to be setup and tested:

You have to ensure that if your Raspberry Pi is pinging and that if your Wi-Fi adapter is being acknowledged and shows up as wLanO when you run ifconfig-a.

Join with a USB console cable, which is optional:
When connected to the access point which is headed by Raspberry Pi, it is helpful for debugging.

After this is being ready, you ought to have a Pi, which should be booting Raspbian which you can merge it with a USB console cable and via the command line edge log into Pi.

When done with this you ought to be able to unite to the Pi as a Wi-Fi contact point and unite to the internet in the course of it.


It is certain to do this by way of SSH using a console cable and on the Ethernet port.

If you are using a console cable, although in the diagram you can see that via the USB console cable the red wire is powering the Pi but we suggest you not to connect the red wire instead use a wall adapter for powering, while keeping green, white and black cable to be connected as it is.


Raspberry Pi – Install TOR :

Fundamentally, this pursues the tor “anonymizing middlebox” write-up at this juncture.We will commence by installing TOR which is an onion routing software.

Log into your pi by Ethernet or console cable and run

sudo apt-get update

sudo apt-get install tor


Check over the tor config file by organizing

sudo nano /etc/tor/torrc

and then on the top of the file do copy and paste.

Log notice file /var/log/tor/notices.log


AutomapHostsSuffixes .onion,.exit

AutomapHostsOnResolve 1

TransPort 9040


DNSPort 53



Now, the access point has to be edited so it is known memorable like Onion Pi. Do not fail to remember to locate a good password, do not use the default password over here.

sudo nano /etc/hostapd/hostapd.conf

Do not fail to remember to do the AP setup step in “Preparation” before this.

Raspberry Pi hostapd

Change your IP routing tables so that associations by means of the Wi-Fi line (wlan0) through the tor software be routed.

Type the subsequent to swill out the previous rules from the IP NAT table

sudo iptables -F

sudo iptables -t nat –F

You will require to append an exclusion for port 22, if you wish to be capable to SSH your Raspberry Pi.

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp –dport 22 -j REDIRECT –to-ports 22

From the subsequent to route all DNS (UDP port 53) from line wlan0 to interior port 53, DNSPort in our torrc

sudo iptables -t nat -A PREROUTING -i wlan0 -p udp –dport 53 -j REDIRECT –to-ports 53

Style the subsequent to route all TCP passage from boundary wlan0 to port 9040 TransPort in our torrc

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp –syn -j REDIRECT –to-ports 9040

After that you can verify that the IP tables are correct with

sudo iptables -t nat –L


If all goes well, we will hoard it to our previous NAT saved file

sudo sh -c “iptables-save > /etc/iptables.ipv4.nat”

It will involuntarily get burdened when on reboot, the networking is setup.


Subsequently we will generate our log file which will be helpful for debugging, with

sudo touch /var/log/tor/notices.log

sudo chown debian-tor /var/log/tor/notices.log

sudo chmod 644 /var/log/tor/notices.log

Verify it with

ls -l /var/log/tor

Create the tor overhaul manually

sudo service tor start

Verify if it is actually running, you can run this at any time you are not certain and if something goes wrong you will spot a big FAIL note.

sudo service tor status

Lastly, make it establish on boot

sudo update-rc.d tor enable


Now you can test.

Raspberry Pi – Test It:

Test your Tor Proxy Server, on your personal computer, verify the existing Wi-Fi networks, you ought to see the Onion Pi network.

raspberry_pi_onion pi Connection

By typing the password that you have entered into the hostapd configuration file


You can ping by opening up a command prompt or a terminal so as to verify if your Raspberry Pi is working or not. Conversely, you will not be able to ping externally because in the course of the proxy, ping is not translated.



About Author

Leave A Reply