I'm hoping someone can help me do what I'm trying to do.
We're talking about the PF firewall.
My goal is to automatically expire table entries, unless they come back before they expire.
An example to clarify:
IP address X is caught executing a bruteforce attack on my SSH port, so I add it to table block22.
I have a cronjob that runs every hour, and expires all entries in table block22 that are older than 24 hours.
However, if IP address X returns within those 24 hours, I want it's timer to be reset, so that it remains quarantined for another 24 hours counting from the last bruteforce attempt.
This way, IP addresses that 'better their lives' are silently removed from the block22 table, while IP addresses that insist on retrying remain there indefinitely.
I was hoping I could do this with the -T zero argument to pfctl in an hourly cronjob. I hoped this would only reset the counters that were not zero, so that the reset time of well-behaving IP addresses would eventually reach 24 hours, and they could be removed from the table.
But unfortunately this resets the statistics for all IP addresses in the table, and not only for those that are non-zero. So no IP address ever expires.
Does anybody have a setup that does roughly what I need?
I would appreciate hearing about it.
Thanks,
Rob
We're talking about the PF firewall.
My goal is to automatically expire table entries, unless they come back before they expire.
An example to clarify:
IP address X is caught executing a bruteforce attack on my SSH port, so I add it to table block22.
I have a cronjob that runs every hour, and expires all entries in table block22 that are older than 24 hours.
However, if IP address X returns within those 24 hours, I want it's timer to be reset, so that it remains quarantined for another 24 hours counting from the last bruteforce attempt.
This way, IP addresses that 'better their lives' are silently removed from the block22 table, while IP addresses that insist on retrying remain there indefinitely.
I was hoping I could do this with the -T zero argument to pfctl in an hourly cronjob. I hoped this would only reset the counters that were not zero, so that the reset time of well-behaving IP addresses would eventually reach 24 hours, and they could be removed from the table.
Code:
pfctl -t block22 -T zero
But unfortunately this resets the statistics for all IP addresses in the table, and not only for those that are non-zero. So no IP address ever expires.
Does anybody have a setup that does roughly what I need?
I would appreciate hearing about it.
Thanks,
Rob