Skip to content

Instantly share code, notes, and snippets.

@jkullick
Last active October 25, 2022 18:33
Show Gist options
  • Save jkullick/d21c6ffa3680ca439619e0da2aa37dae to your computer and use it in GitHub Desktop.
Save jkullick/d21c6ffa3680ca439619e0da2aa37dae to your computer and use it in GitHub Desktop.
Route all Traffic through Tor for specific User on Linux with IPTables
iptables -A OUTPUT -p icmp -j REJECT
iptables -t nat -A OUTPUT ! -o lo -p tcp -m owner --uid-owner $USER -m tcp -j REDIRECT --to-ports 9040
iptables -t nat -A OUTPUT ! -o lo -p udp -m owner --uid-owner $USER -m udp --dport 53 -j REDIRECT --to-ports 53
iptables -t filter -A OUTPUT -p tcp -m owner --uid-owner $USER -m tcp --dport 9040 -j ACCEPT
iptables -t filter -A OUTPUT -p udp -m owner --uid-owner $USER -m udp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT ! -o lo -m owner --uid-owner $USER -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment