Page 1 of 1

Firewall filter due date

Posted: Sun Mar 01, 2020 3:26 am
by wingolo
Hi,
I tried to search for this in the forum and google, but haven't found anything satisfying...

Is there a way to set some kind of expiry date for filter, nat and mangle rules? Would be very useful to have a rule disabled after that date.
I'm thinking about something like the timeout in address list, which will disable the rule instead of remove it.

Maybe this could be achieved using scripts, but for now I have found this way very confusing, and didn't help to keep configuration clean.

Any thoughts or suggestions?

Re: Firewall filter due date

Posted: Sun Mar 01, 2020 3:35 am
by macsrwe
If you were clever, and your specific requirement suited such a strategy, you could configure your rules to use address lists instead of addresses, and then populate those address lists with expiring entries. Otherwise, I can't think of anything short of scripting.

Re: Firewall filter due date

Posted: Sun Mar 01, 2020 4:31 am
by wingolo
Well... I've already tried this solution, but didn't help much.

For example, in case of a d-nat rule which redirect all from input of an interface to a web-server:
chain=dstnat action=dst-nat to-addresses=192.168.220.30 protocol=tcp in-interface-list=Develop dst-port=80 log=no log-prefix=""
In this case can't use address-lists.

Re: Firewall filter due date

Posted: Sun Mar 01, 2020 4:50 am
by macsrwe
And yet that rule DOES take a dst-address-list argument that has to be matched in order to invoke it... so put the router's own WAN address in an address list with an expiration time (in addition to a non-expiring bogus address, just to be safe) and the dst-nat will stop working when that entry expires.

Re: Firewall filter due date

Posted: Sun Mar 01, 2020 2:23 pm
by wingolo
Good tip!
So, as long as I can use address-list, the "expiration date" can be achieved.
/ip firewall address-list
address=192.168.220.1 list=TEST_WEB timeout="90d 00:00:00"

/ip firewall nat
chain=dstnat action=dst-nat to-addresses=192.168.220.30 protocol=tcp dst-address-list=TEST_WEB in-interface-list=Develop  dst-port=80 log=no log-prefix=""
Thanks @macsrwe

Anyway, I take this opportunity to request or at least suggest, to consider this "exipired time" in rules for filters, nat and mangle, so it could meybe have a graphic worning (red text?) for those expired rules.

Does anyone think this could be useful?

Thanks!

Re: Firewall filter due date

Posted: Sun Mar 01, 2020 8:04 pm
by macsrwe
Maybe it would be worthwhile if you could describe a situation that would require a NAT rule to deactivate itself after a specific period, because my imagination is failing me.