我不希望我的服务器接受来自 Tor 网络的任何连接。
有没有办法阻止我的公共服务器上的所有 TOR 流量事件?
信息安全
网络
托
2021-09-06 13:01:38
1个回答
请参阅官方 Tor 文档中的我想从我的服务中禁止 Tor 网络。
Tor 项目提供了一个列表,其中包含可以访问您的服务的所有出口节点的 IP,使用查询字符串参数告诉它您的服务的 IP 和端口,例如:https ://check.torproject.org/cgi-bin/ TorBulkExitList.py?ip=8.8.8.8&port=443。
然后,您可以遍历结果,将它们拆分为每个换行符,忽略以“#”开头的行,最后-J DROP为每个结果添加一个 IPtables 操作,或者使用一个IPset,这样可以在如此大量的主机上为您提供更好的性能,某事像这样应该可以解决问题:
ipset -N tor iphash # create a new set named "tor"
# get the list, don't forget to put your service's IP in the query string
curl -s https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=8.8.8.8 | sed '/^#/d' | while read IP
do
# add each IP address to the set, silencing the warnings for IPs that have already been added
ipset -q -A tor $IP
done
iptables -A INPUT -m set --match-set tor src -j DROP # block any IP in this set in IPtables
他们还提供了一个基于 DNS 的列表,但它仍处于实验阶段,所以我建议你坚持第一个选项,它也更容易使用。