如何通过Tor(洋葱路由器)路由所有互联网流量?


14

您能解释一下如何通过Tor路由所有互联网流量吗?我正在使用Ubuntu,但我真的不知道该怎么做。实际上,我仅将tor用于Twitter,并且担心DNS泄漏。所以我需要把所有的东西都通过tor。


Answers:


15

您正在寻找的是:TransparentProxy

通过Tor进行本地重定向

添加到您的torrc:

VirtualAddrNetwork 10.192.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 53

这样,您可以在Ubuntu 53端口和透明代理上设置DNS服务器:127.0.0.1:9040。

接下来,添加到您的/etc/resolv.conf

nameserver 127.0.0.1

这样,您可以防止DNS泄漏出系统。

因此,请根据您的防火墙配置防火墙,以确保除Tor用户外,任何连接都将通过TransPort进行:

#!/bin/sh

# destinations you don't want routed through Tor
NON_TOR="192.168.1.0/24 192.168.0.0/24"

# the UID Tor runs as
TOR_UID="109"

# Tor's TransPort
TRANS_PORT="9040"

iptables -F
iptables -t nat -F

iptables -t nat -A OUTPUT -m owner --uid-owner $TOR_UID -j RETURN
iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 53
for NET in $NON_TOR 127.0.0.0/9 127.128.0.0/10; do
 iptables -t nat -A OUTPUT -d $NET -j RETURN
done
iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT

iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
for NET in $NON_TOR 127.0.0.0/8; do
 iptables -A OUTPUT -d $NET -j ACCEPT
done
iptables -A OUTPUT -m owner --uid-owner $TOR_UID -j ACCEPT
iptables -A OUTPUT -j REJECT

继续阅读官方Wiki,有一种针对这种方法的攻击和一种解决方案:IsolatingProxy

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.