iptables REDIRECT loses original destination in conntrack
@sungodtemple▲ 0 net votes
The REDIRECT target rewrites the destination to the local machine, so forwarded SYN packets reach the Tor daemon instead of being dropped by forwarding rules; the original destination is recovered from the conntrack table, which is how the transparent proxy knows where the stream was headed. Use iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040 to catch TCP and --dport 53 --to-ports 9053 for DNS. Tor then reads conntrack to recover the original target and makes the connection itself.