仅通过 VPN 使用 rTorrent

仅通过 VPN 使用 rTorrent

如何让 rTorrent 使用 VPN(OpenVPN),而服务器上的其他应用程序使用常规互联网连接?服务器运行的是 debian。

答案1

将监听套接字和传出连接绑定到此网络接口地址。

rtorrent -b a.b.c.d

阻止除 49164 到 49164(默认端口范围)之外的所有端口

iptables -A INPUT -i "Interface (ex. tun1)" -j DROP
iptables -A OUTPUT -i "Interface (ex. tun1)" -j DROP
iptables -A FORWARD -i "Interface (ex. tun1)" -j DROP

iptables -A INPUT -p tcp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT
iptables -A INPUT -p udp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT
iptables -A OUTPUT -p tcp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT
iptables -A OUTPUT -p udp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT

或者

iptables -A INPUT -i "Interface (ex. tun1)" -j ACCEPT
iptables -A OUTPUT -i "Interface (ex. tun1)" -j DROP
iptables -A FORWARD -i "Interface (ex. tun1)" -j DROP

iptables -A OUTPUT -p tcp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT
iptables -A OUTPUT -p udp --sport 49164:49164 --dport 49164:49164 -i "Interface (ex. tun1)" -j ACCEPT

或针对特定用户

iptables -A INPUT -i "Interface (ex. tun1)" -j ACCEPT
iptables -A OUTPUT -i "Interface (ex. tun1)" -j DROP
iptables -A FORWARD -i "Interface (ex. tun1)" -j DROP

iptables -A OUTPUT -o "Interface (ex. tun1)" -m owner --uid-owner "USER UID (ex. 2021) or USER NAME (ex. ithenrik)" -j REJECT

http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.html
https://wiki.archlinux.org/index.php/RTorrent#Port_configuration

相关内容