一起使用 fireHOL IP 列表、ipset 和 iptables

Using fireHOL IP lists, ipset and iptables together

我想在我的 centOS 网络服务器上同时使用 fireHOL ip 列表:http://iplists.firehol.org、ipset 和 iptables。

我已经安装了 fireHOL 列表并更新了它生成的 IP 列表。

它创建的 IP 列表保存在:/etc/firehol/ipsets (https://github.com/firehol/blocklist-ipsets/wiki/Downloading-IP-Lists#where-are-the-ipsets)

我已经安装了ipset。

我已经安装并运行了 iptables(通过 CSF/LFD 控制)。

如何将 IP 列表、ipset 和 iptables 绑定在一起,以便通过 iptables (https://github.com/firehol/blocklist-ipsets/wiki/Downloading-IP-Lists#updating-the-ipsets-in-kernel) 阻止列表?

感谢您的帮助。

我不知道如何使用 CSF/LFD,但如果您使用 FireHOL,则每个 ipset 都需要如下内容。

假设您对 ipset dshield 感兴趣。 在您的 firehol.conf 顶部,您应该添加以下内容:

ipset4 create dshield hash:net
ipset4 addfile dshield ipsets/dshield.netset
blacklist4 input inface ${wan} log "BLACKLIST dshield" ipset:dshield

当然,以上是片段。您需要正确配置 firehol.conf。

然后update-ipsets会在内核更新时自动更新dshield

所以总体思路:

  1. 使用您感兴趣的 IP 列表名称创建 ipset
  2. 用update-ipsets生成的文件内容初始化它
  3. 创建一个使用您创建的 ipset 的黑名单
  4. update-ipsets 会自动更新内核中的ipset

firehol 负责 1、2、3 和 4 号的 update-ipsets。 检查这个:https://github.com/firehol/firehol/wiki/Working-with-IPSETs

或者: 您可以在控制台上通过 运行 ipset 命令执行 1 和 2。 您可以使用防火墙(它必须支持 ipsets)或通过控制台上的 运行 iptables 命令执行 3。

如果您不知道该怎么做,最简单的方法就是使用 firehol。检查它的文档 (http://firehol.org/guides/firehol-welcome/).