我正在此处下载 Amazon Web Services 的 CIDR 列表:
https://ip-ranges.amazonaws.com/ip-ranges.json
然后将它们放在带有以下行的 ipset 上:
sudo ipset -q -A tor $ip
Run Code Online (Sandbox Code Playgroud)
并使用以下行使用 iptables 进行阻塞:
sudo iptables -A INPUT -m set --match-set tor src -j DROP
Run Code Online (Sandbox Code Playgroud)
ipset tor 中总共有大约 65,000 个 IP 。它还阻止了 Tor IP 和其他一些 IP,这对这些 IP 工作正常,但由于某种原因,它似乎无法阻止任何 Amazon IP。
有任何想法吗?
完整规则列表:
sudo ipset -N whitelist nethash
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -m set --match-set whitelist src -j ACCEPT
sudo iptables -N BLOCK24
sudo iptables -A …Run Code Online (Sandbox Code Playgroud)