Skip to content

Rdx1S/TOR-LINUX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

🧅 Route All Traffic Through Tor on Kali Linux

English · Українська

Force all outgoing traffic on Kali Linux through the Tor network, and make it persist across reboots with a systemd service.

Tor Kali Linux

⚠️ For educational and authorized use only. Routing all traffic through Tor changes your network behavior significantly. Use it responsibly and only on systems you own or are permitted to test.


📑 Table of Contents


1. Install Tor

sudo apt update && sudo apt upgrade -y
sudo apt install tor

2. Configure Tor

Edit the Tor configuration file:

sudo nano /etc/tor/torrc

Uncomment the SocksPort 9050 line (or set any other free port) as the SOCKS port.


3. Install Privoxy

sudo apt install privoxy

Edit the Privoxy configuration:

sudo nano /etc/privoxy/config
  • Uncomment listen-address localhost:8118 and replace localhost with 127.0.0.1.
  • Add the following line to the end of the file to forward traffic to Tor:
forward-socks5 / 127.0.0.1:9050 .

4. Enable IP forwarding

Edit the sysctl configuration:

sudo nano /etc/sysctl.conf

Uncomment the line:

net.ipv4.ip_forward=1

5. Apply the changes

sudo sysctl -p

6. Redirect traffic with iptables

Add a NAT rule that redirects outgoing TCP traffic through Privoxy:

sudo iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-ports 8118

All your traffic should now be routed through Tor. Verify it by checking your public IP — it should belong to the Tor network:

curl ident.me

7–12. Persist across reboots

The iptables rule resets on reboot. Wrap it in a script and register it as a systemd service so it runs automatically.

7. Create a script in /usr/local/bin (the standard location for custom binaries):

sudo nano /usr/local/bin/tort.sh

8. Add the following:

#!/bin/bash
iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-ports 8118

9. Make it executable:

sudo chmod ugo+x /usr/local/bin/tort.sh

10. Create a systemd unit that runs the script:

sudo systemctl edit --force --full script.service

This opens a text editor — paste:

[Unit]
Description=My Script Service
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/local/bin/tort.sh

[Install]
WantedBy=multi-user.target

💡 In ExecStart you can specify either the path to the script or the raw iptables command directly. Using a script is more convenient — you can simply edit it to add more commands to run at boot.

11. Enable the service so it starts on boot:

sudo systemctl enable script

12. If systemd doesn't see the service, reload the unit definitions:

sudo systemctl daemon-reload

About

Route all traffic through Tor on Kali Linux

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors