I use PF to route traffic to an http server in a jail unless the incoming IP is on a blocklist.
Here is the rule:
I have recently installed security/crowdsec-firewall-bouncer which needs a second table called crowdsec-blacklist. I therefore need to add the second table to the rule, but can't get the syntax right to do what I want.
The problem is rdr rules have to come before block rules so I need an rdr rule which atomically combines the two tables and then passes only if the IP address is in neither. How can I do that? If I add a separate rule the first one to match will pass and the second one won't be tested.
If I add the second table in a list I can't negate the list, only the individual tables, giving a NAND rather than a NOR, passing anything not in both tables. What I want is something like
but that's a syntax error.
It would be far simpler if I could just put a block rule in before these but that's an error too.
How do I do this?
Update: I've worked it out! I remove the pass and table from the rdr rules and then let the later block rules handle the tables.
Here is the rule:
Code:
rdr pass on $ext_if inet proto tcp from !<badaddresses> to port https -> $WEB_IN_ADDR
port https
I have recently installed security/crowdsec-firewall-bouncer which needs a second table called crowdsec-blacklist. I therefore need to add the second table to the rule, but can't get the syntax right to do what I want.
The problem is rdr rules have to come before block rules so I need an rdr rule which atomically combines the two tables and then passes only if the IP address is in neither. How can I do that? If I add a separate rule the first one to match will pass and the second one won't be tested.
If I add the second table in a list I can't negate the list, only the individual tables, giving a NAND rather than a NOR, passing anything not in both tables. What I want is something like
Code:
rdr pass on $ext_if inet proto tcp from !{<crowdsec-blacklist>, <badaddresses> }
to port https -> $WEB_IN_ADDR port https
It would be far simpler if I could just put a block rule in before these but that's an error too.
How do I do this?
Update: I've worked it out! I remove the pass and table from the rdr rules and then let the later block rules handle the tables.
Code:
rdr on $ext_if inet proto tcp to port https -> $WEB_IN_ADDR port https