Koh*_*ese 0 firewall iptables amazon-web-services
我正在此处下载 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 BLOCK24 -m recent --name blocked --set
sudo iptables -A INPUT -m state --state NEW -m recent --set
sudo iptables -A INPUT -m state --state NEW -m recent --update --seconds 300 --hitcount 200 -j BLOCK24
sudo iptables -A INPUT -m recent --name blocked --rcheck --seconds 86400 -j BLOCK24
sudo iptables -A BLOCK24 -j LOG --log-prefix='[NETFILTER] ' --log-level 7
sudo iptables -A BLOCK24 -j REJECT
Run Code Online (Sandbox Code Playgroud)
然后首先我运行这些来销毁并重新创建阻止列表:
sudo iptables -D INPUT -m set --match-set tor src -j DROP
sudo ipset destroy tor
sudo ipset -N tor iphash
Run Code Online (Sandbox Code Playgroud)
添加 cira 65K IP:
sudo ipset -q -A tor $ip
Run Code Online (Sandbox Code Playgroud)
将 ipset 添加到 iptables:
sudo iptables -A INPUT -m set --match-set tor src -j DROP
Run Code Online (Sandbox Code Playgroud)
同样,除了亚马逊之外,一切都被阻止了。
| 归档时间: |
|
| 查看次数: |
397 次 |
| 最近记录: |