Hmm ich hab eine Debian VM als transparenten Tor Proxy am laufen... Da sehen meine regeln in etwa so aus
Erster Befehl damit ssh noch zugänglich ist
sudo iptables -t nat -A PREROUTING -i (int Schnittstelle) -p tcp --dport 22 -j REDIRECT --to-ports 22
DNS soll über den Dienst dnsmasq laufen und nicht tor
$ sudo iptables -t nat -A PREROUTING -i (int Schnittstelle) -p udp --dport 53 -j REDIRECT --to-ports 53
Alles andere an Tor leiten
$ sudo iptables -t nat -A PREROUTING -i (int Schnittstelle) -p tcp --syn -j REDIRECT --to-ports 9040
---------- Post added at 22:17 ---------- Previous post was at 21:48 ----------
Ich hab das hier gefunden für localen Traffic umleiten...
1.) In der /etc/tor/torrc musst du folgende Zeilen reinschreiben, egal ob am Anfang, in der Mitte oder am Ende.
VirtualAddrNetworkIPv4 172.16.0.0/12
TransPort 9040
AutomapHostsOnResolve 1
DNSPort 9053
2.) Per iptables routen wir den gesamten TCP Verkehr durch TOR. Du kannst das in einem Script abspeichern und bei Bedarf mit laden oder bei jedem Systemstart in dem du es in die /etc/rc.local reinschreibst. Nicht vergessen es mit chmod +x <scriptname> ausführbahr zu machen.
#!/bin/bash
# Let us call this script anonymity.bash and do some netfilter rules on the local machine.
# Load the Kernel modules
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack_irc
modprobe ip_conntrack_ftp
modprobe iptable_filter
modprobe iptable_nat
modprobe ipt_REJECT
modprobe xt_recent
modprobe ipt_mac
# Remove all rules
iptables -F
iptables -t nat -F
iptables -X
# Default Policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Allow Established and Related connetcions
# Ehternet
iptables -A INPUT -i eth+ -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o eth+ -m state --state ESTABLISHED,RELATED -j ACCEPT
# Wlan
iptables -A INPUT -i wlan+ -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o wlan+ -m state --state ESTABLISHED,RELATED -j ACCEPT
#Umts
iptables -A INPUT -i ppp+ -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o ppp+ -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow localhostloop
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Ruleset for Tor Transparent Proxy
iptables -t nat -A OUTPUT -o lo -j RETURN
iptables -t nat -A OUTPUT -m owner --uid-owner "debian-tor" -j RETURN
iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 9053
iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports 9040
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m owner --uid-owner "debian-tor" -j ACCEPT
for NET in 127.0.0.0/8; do
iptables -A OUTPUT -d $NET -j ACCEPT
done
iptables -A OUTPUT -p udp -m udp --dport 123 -j ACCEPT
iptables -A OUTPUT -j REJECT