Created
October 13, 2013 03:30
-
-
Save mouseroot/6957827 to your computer and use it in GitHub Desktop.
iptables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#toriptables.sh | |
# I learned this from https://wiki.torproject.org/noreply/TheOnionRouter/TransparentProxy | |
#Reject all ICMP packets because they have no owner which creates a leak | |
iptables -A OUTPUT -p icmp -j REJECT | |
#All traffic for the user root will go through tor | |
iptables -t nat -A OUTPUT ! -o lo -p tcp -m owner --uid-owner root -m tcp -j REDIRECT --to-ports 9040 | |
iptables -t nat -A OUTPUT ! -o lo -p udp -m owner --uid-owner root -m udp --dport 53 -j REDIRECT --to-ports 53 | |
iptables -t filter -A OUTPUT -p tcp -m owner --uid-owner root -m tcp --dport 9040 -j ACCEPT | |
iptables -t filter -A OUTPUT -p udp -m owner --uid-owner root -m udp --dport 53 -j ACCEPT | |
iptables -t filter -A OUTPUT ! -o lo -m owner --uid-owner root -j DROP | |
#All traffic through your user will go through tor | |
iptables -t nat -A OUTPUT ! -o lo -p tcp -m owner --uid-owner anonymous -m tcp -j REDIRECT --to-ports 9040 | |
iptables -t nat -A OUTPUT ! -o lo -p udp -m owner --uid-owner anonymous -m udp --dport 53 -j REDIRECT --to-ports 53 | |
iptables -t filter -A OUTPUT -p tcp -m owner --uid-owner anonymous -m tcp --dport 9040 -j ACCEPT | |
iptables -t filter -A OUTPUT -p udp -m owner --uid-owner anonymous -m udp --dport 53 -j ACCEPT | |
iptables -t filter -A OUTPUT ! -o lo -m owner --uid-owner anonymous -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment