I have configured a router to route all traffic from an internal interface through the TOR network. Therefore, every client that uses this router as its Gateway will access the internet through TOR, regardless which application is running. This is my setup on the router:
- eth2 is the internal device (192.168.1.1) - TOR listens on eth2 for connections from LAN clients - eth0 is the device that connects to the internet
My torrc setup:
... TransPort 192.168.1.1:9040 DNSPort 192.168.1.1:9053 ...
My iptables on the Gateway (192.168.1.3 is the client that may connect):
*nat :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] -A PREROUTING -i eth2 -p udp -m udp --dport 53 -j REDIRECT --to-ports 9053 -A PREROUTING -i eth2 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j REDIRECT --to-ports 9040 COMMIT *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT DROP [0:0] -A INPUT -s 192.168.1.3/32 -i eth2 -p udp -m udp --dport 9053 -j ACCEPT -A INPUT -s 192.168.1.3/32 -i eth2 -p tcp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -i eth0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A OUTPUT -d 192.168.1.3/32 -o eth2 -j ACCEPT -A OUTPUT -o eth0 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT -A OUTPUT -o lo -j ACCEPT COMMIT
To test that no DNS requests are leaked I used the method described here. However, it does not give an example of what the expected results should be. So I issued the following commands and got the following output:
$ tcpdump -pni eth2 'port domain' 18:59:33.158511 IP 192.168.1.3.53413 > 18.104.22.168.53: 20625+ AAAA? check.torproject.org. (38) 18:59:33.212772 IP 192.168.1.3.53494 > 22.214.171.124.53: 15545+ A? check.torproject.org. (38) 18:59:33.448883 IP 126.96.36.199.53 > 192.168.1.3.53413: 20625 NXDomain 0/0/0 (38) 18:59:33.451545 IP 192.168.1.3.39311 > 188.8.131.52.53: 58625+ AAAA? check.torproject.org. (38) 18:59:33.539581 IP 184.108.40.206.53 > 192.168.1.3.53494: 15545 1/0/0 A 220.127.116.11 (54) 18:59:33.808832 IP 18.104.22.168.53 > 192.168.1.3.39311: 58625 NXDomain 0/0/0 (38) 18:59:33.810768 IP 192.168.1.3.60437 > 22.214.171.124.53: 61942+ A? check.torproject.org. (38) 18:59:34.072359 IP 126.96.36.199.53 > 192.168.1.3.60437: 61942 1/0/0 A 188.8.131.52 (54)
I ran also ran the commands on the outgoing device eth0
tcpdump -pni eth0
which yielded no output at all.
I have two questions:
- Does the output of
tcpdumpproof that no DNS requests from the client were leaked?
- Are the
iptablesrules reasonable for my purpose?