Linux Netfilter discussions
 help / color / mirror / Atom feed
* ipset not completely working in mangle:PREROUTING
@ 2026-05-26  0:57 imnozi
  2026-05-26  1:57 ` Kerin Millar
  2026-05-27  1:42 ` imnozi
  0 siblings, 2 replies; 6+ messages in thread
From: imnozi @ 2026-05-26  0:57 UTC (permalink / raw)
  To: netfilter

iptables v1.8.7 (legacy)
ipset v6.34, protocol version: 6

I have four sets:
  - blockSetHost (hash:ip)
  - blockSetNet (hash:net)
  - whiteSetHost (hash:ip)
  - whiteSetNet (hash:net)

I added rules to match the block sets in filter to INPUT, FORWARD and OUTPUT. The rules match and jump to chain blDrop. In blDrop, if either white set matches, control returns. If no match, the packet is dropped.

This works well in filter. But there's one artifact. The blocked packets are 'accounted' to the internal server where they would have gone.

To fix this, I added the rules below to mangle. Here in mangle, the white sets never match and all of the packets (that matched the block sets) are dropped.

Is this another instance of 'it doesn't work in mangle or in PREROUTING'?

Thanks,
Neal

----
The rules used in mangle; eth3 is internet:
-A blDrop -m set --match-set whiteSetNet src -j RETURN
-A blDrop -m set --match-set whiteSetHost src -j RETURN
-A blDrop -j DROP

-A PREROUTING -i eth3 -p udp -m set --match-set blockSetHost src -m state --state NEW -j blDrop
-A PREROUTING -i eth3 -p tcp -m set --match-set blockSetHost src -m state --state NEW -j blDrop
-A PREROUTING -i eth3 -p udp -m set --match-set blockSetNet src -m state --state NEW -j blDrop
-A PREROUTING -i eth3 -p tcp -m set --match-set blockSetNet src -m state --state NEW -j blDrop

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-27  1:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26  0:57 ipset not completely working in mangle:PREROUTING imnozi
2026-05-26  1:57 ` Kerin Millar
2026-05-26  3:57   ` imnozi
2026-05-26  7:51     ` Jozsef Kadlecsik
2026-05-26 10:24       ` Slavko
2026-05-27  1:42 ` imnozi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox