Skip to content

Instantly share code, notes, and snippets.

@fire1ce
Last active November 4, 2023 06:39
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save fire1ce/bc8d0ab9e1aeb4c83b46a22df7846625 to your computer and use it in GitHub Desktop.
Save fire1ce/bc8d0ab9e1aeb4c83b46a22df7846625 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 TOR Access Point Router

THIS GIST WON'T BE UPDATED ANY MORE (24/10/18)

Follow the progress of this project here 3os.org Raspberry Pi 3 TOR Access Point Router Project

Network: Router RJ45 <--> Ethernet Port on Raspberry <--> TOR <--> Raspberry WIFI AC <--> WIFI CLIENT

# -- Download Rasbian Strech Lite from: https://www.raspberrypi.org/downloads/raspbian/
# -- Burn Image to SD-Card. 
# -- Boot Raspberry Pi 3. 

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git 
sudo raspi-config
# -- Change User Password
# -- Enable SSH In Interface Options
sudo reboot

# SSH TO Raspberry Pi 3

git clone https://github.com/unixabg/RPI-Wireless-Hotspot.git
cd RPI-Wireless-Hotspot
sudo ./install

# -- "Y" to agree to terms
# -- "Y" to use preconfigured DNS
# -- "Y" to use Unblock-Us DNS servers
# -- "N" for WiFi defaults
# -- Type in a new WiFi password (it will be checked)
# -- Type in a new SSID
# -- Type in your desired WiFi channel (1, 6, 11)
# -- Type "N" when asked - "Are you using a rtl871x chipset?" -- 
# -- Type "N" for chromecast support (unless you plan to use a chromecast w/RasTor)

sudo reboot
sudo apt-get update && sudo apt-get upgrade

# -- Connect to Your new SSID with a Phone and check if you have full Internet Connection.

sudo apt-get install tor
sudo nano /etc/tor/torrc

# -- Add the following just below the first set of comments:

Log notice file /var/log/tor/notices.log
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1
TransPort 9040
TransListenAddress 192.168.42.1
DNSPort 53
DNSListenAddress 192.168.42.1

# -- iptable routes:

sudo iptables -F && sudo iptables -t nat -F
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

# -- Check your routes:

sudo iptables -t nat -L

# -- if all routs looks like about:

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

# -- Create log file:

sudo touch /var/log/tor/notices.log 
sudo chown debian-tor /var/log/tor/notices.log && sudo chmod 644 /var/log/tor/notices.log

# -- Start TOR:

sudo service tor start

# -- Check to see if the service is running:

sudo service tor status

# -- Run TOR Service at Boot:

sudo update-rc.d tor enable
sudo reboot

# -- Test for TOR service is running after reboot, connect to the WIFI. 
# -- DONE -- #


# -- Optional: Install Monit Service to reload Tor Serivce if Down

sudo apt-get install monit
sudo nano /etc/monit/monitrc

# -- add those lines to the end of the config:

check process gdm with pidfile /var/run/tor/tor.pid
   start program = "/etc/init.d/tor start"
   stop program = "/etc/init.d/tor stop"
   
# -- realod and add Monit to startup
sudo monit reload
sudo update-rc.d monit enable
@me9718
Copy link

me9718 commented Jan 5, 2019

hello, i install this setup on my raspberry pi and it works fine. i want raspi to use Tor as a client while connecting to the internet with Ethernet cable. is there a set up for that raspi (that use Tor) be a client only or it can switch between AccessPoint mode and client mode?

@dnkls
Copy link

dnkls commented Jan 13, 2019

All work perfect but cant access to .onion sites :(

@Fl0-0
Copy link

Fl0-0 commented Mar 3, 2019

.onion hidden services works with iptables rules:

-A PREROUTING -i wlan0 -p udp -m udp --dport 53 -j REDIRECT --to-ports 53
-A PREROUTING -i wlan0 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j REDIRECT --to-ports 9040
-A PREROUTING -i wlan0 -p tcp -d 10.192.0.0/10 -j REDIRECT --to-port 9040

@bezo21
Copy link

bezo21 commented May 11, 2019

Hello! Great guide but i keep getting the same problem and i cannot fix it!
The status keep saying
active: active (exited)

Can you please help me....

@fire1ce
Copy link
Author

fire1ce commented Nov 28, 2019

Hello! Great guide but i keep getting the same problem and i cannot fix it!
The status keep saying
active: active (exited)

Can you please help me....

follow updated guide:
TOR-Pi

@fire1ce
Copy link
Author

fire1ce commented Nov 28, 2019

The Guide was updated
follow updated guide:
TOR-Pi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment