要求:Debian系统
1:先安装SS

2.

apt install tor

3.

vi /etc/tor/torrc

4.在torrc中添加以下内容(前四条可以不加)

ClientOnly 0
StrictNodes 1
ExcludeNodes {hk},{cn},{mo},{ru}
ExitNodes {us},{jp},{sg},{kp},{gb},{nz},{au},{tw}
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 5353

这四行参数,第一行是设置为客户端,这个可有可无,默认设定也是
第二行是作为TOR运行排除节点的参数,TOR会根据排除节点设定网路
第三行是设定要排除的节点,这裡是香港,支国,澳门和俄罗斯
第四行是设置出口,这里除英美外,都是亚洲出口节点,希望速度提高

5.新建一个文件叫tor.sh
添加以下内容

#!/bin/sh
# destinations you do not want routed through Tor
NON_TOR="192.168.1.0/24 192.168.0.0/24"
# 填tor的uid
TOR_UID="111"
# 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 5353
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

这里注意UID,需要确认下自己tor创建用户的ID

cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
_apt:x:104:65534::/nonexistent:/bin/false
messagebus:x:105:109::/var/run/dbus:/bin/false
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
debian-tor:x:107:111::/var/lib/tor:/bin/false
id debian-tor
uid=107(debian-tor) gid=111(debian-tor) groups=111(debian-tor)

6.

chmod +x tor.sh
./tor.sh
service tor restart

原文来自:

https://www.hostloc.com/thread-668684-1-1.html

说点什么
支持Markdown语法
好耶,沙发还空着ヾ(≧▽≦*)o
Loading...