iptables 忽略自訂鏈中的 REJECT,但在主鏈中有效

iptables 忽略自訂鏈中的 REJECT,但在主鏈中有效

我為 smtp 伺服器配置了一個帶有fail2ban的伺服器。現在,fail2ban 正確地禁止了這些 IP,我可以在fail2ban 的 iptables 鏈中看到它們。然而,核心似乎忽略了 iptables failure2ban 鏈 REJECT 規則。相反,如果我將相同的規則添加到 INPUT 鏈,它就會起作用。

的輸出iptables -L -n -v是:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  207  8339 f2b-postfix  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport dports 80,443,25,587,110,995,143,993,4190
   17  2172 REJECT     all  --  *      *       141.98.11.68         0.0.0.0/0            reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain f2b-postfix (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     all  --  *      *       141.98.11.68         0.0.0.0/0            reject-with icmp-port-unreachable
  207  8339 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

正如您所看到的,鏈REJECT中的規則f2b-postfix被忽略(0 個資料包),並且所有資料包最終都在規則中RETURN。但是,如果我REJECTINPUT鏈中添加相同的規則,它就會起作用並拒絕該資料包。

為了確保我還檢查了原始 iptables 配置:

-A INPUT -s 141.98.11.68/32 -j REJECT --reject-with icmp-port-unreachable
-A f2b-postfix -s 141.98.11.68/32 -j REJECT --reject-with icmp-port-unreachable

但這兩個規則是相同的。

任何想法?

相關內容