fwbuilder/iptables 手动脚本+启动时自动生成规则?

fwbuilder/iptables 手动脚本+启动时自动生成规则?

Fedora 11

我们之前的 IT 人员在防火墙上设置 iptable 规则的方式让我感到困惑,而且他没有记录任何内容。我希望有人能帮我理解一下。

iptables 服务显然在启动时启动,但/etc/sysconfig/iptables文件未受影响(默认值)。

我发现/etc/rc.local他在做这样的事情:

# We have multiple ISP connections on our network.
# The following is about 50+ rules to route incoming and outgoing
# information. For example, certain internal hosts are specified here
# to use ISP A connection while everyone else on the network uses
# ISP B connection when access the internet.
ip rule add from 99.99.99.99 table Whatever_0
ip rule add from 99.99.99.98 table Whatever_0
ip rule add from 99.99.99.97 table Whatever_0
ip rule add from 99.99.99.96 table Whatever_0
ip rule add from 99.99.99.95 table Whatever_0
ip rule add from 192.168.1.103 table ISB_A
ip rule add from 192.168.1.105 table ISB_A
ip route add 192.168.0.0/24 dev eth0 table ISB_B
# etc...

然后在文件末尾附近,在他刚刚声明的所有 IP 规则之后,他得到了以下内容:

/root/fw/firewall-rules.fw

他正在执行由 自动生成的防火墙规则文件fwbuilder

一些问题

  1. 为什么他要声明所有这些 IP 规则,rc.local而不是像所有其他规则一样声明它们fwbuilder?这样做有什么好处或必要性吗?或者这只是一种组织不良的防火墙规则实施方式?

  2. 为什么他在执行fwbuilder脚本之前声明 IP 规则?我认为脚本首先要做的一件事fwbuilder就是在声明所有新规则之前删除所有现有规则。我错了吗?如果是这样的话,fwbuilder 脚本基本上只会删除在 rc.local 中定义的所有 IP 规则。这有意义吗?

  3. 为什么他在启动时在 rc.local 中执行所有这些内容,而不是仅仅用来保存在运行时实施的iptables-save防火墙设置?/etc/sysconfig/iptables

答案1

您显示的 IP 规则与 iptables 没有直接关系。该ip命令控制高级路由。您的系统已设置了一些内容来执行拆分路由。该iptables命令控制防火墙 (netfilter) 规则。

iptables-save/iptables-restore 实际上并不直接对路由和规则执行任何操作。

查看Linux 高级路由和流量控制指南有关使用 iproute2 可以执行的操作的详细说明。

相关内容