| 1 |
zone { |
| 2 |
localhost |
| 3 |
public |
| 4 |
} |
| 5 |
|
| 6 |
iplist { |
| 7 |
# List of known good hosts, don't ban these |
| 8 |
@good 192.168.0.0/24 foobar.fi |
| 9 |
|
| 10 |
# List containing banned IP addresses. They will be banned for 5 minutes. |
| 11 |
@banned dynamic=yes element_timeout=5m |
| 12 |
} |
| 13 |
|
| 14 |
public-localhost { |
| 15 |
# Drop all new traffic if source IP address is in @banned iplist. |
| 16 |
# Update/reset ban expire timeout. Add this as first rule. |
| 17 |
saddr @banned iplist_update saddr @banned drop log + ":banned" |
| 18 |
|
| 19 |
# Allow SSH from known good hosts and others with rate limit. |
| 20 |
# If there are more than 5/minute connections add them to @banned iplist. |
| 21 |
ssh saddr @good |
| 22 |
ssh saddr_rate "5/minute burst 5" |
| 23 |
ssh iplist_update saddr @banned drop log + ":ban-ssh" |
| 24 |
|
| 25 |
# ...other normal rules, with or without similar rate limit banning... |
| 26 |
|
| 27 |
# Instead of normal final "drop log" rule: |
| 28 |
# - Allow 2/min dropped connections without banning. |
| 29 |
# - Somebody is port scanning us. Add IP address to @banned iplist. |
| 30 |
# - Make sure @good addresses are never banned. |
| 31 |
saddr @good drop log |
| 32 |
saddr_rate "2/minute burst 10" drop log |
| 33 |
iplist_update saddr @banned drop log + ":ban-portscan" |
| 34 |
} |