summary refs log tree commit diff stats
path: root/system/services/fail2ban/default.nix
diff options
context:
space:
mode:
authorsils <sils@sils.li>2023-04-11 10:55:18 +0200
committersils <sils@sils.li>2023-04-11 10:55:18 +0200
commit5a6dd9797b67c08d58236956fbb43b7fe57f5730 (patch)
tree27418564bc75d03c66c0e5cf5209f0b66e625998 /system/services/fail2ban/default.nix
parentFix(services): Remove Minecraft (diff)
parentChore(flake): Update (diff)
downloadnixos-server-5a6dd9797b67c08d58236956fbb43b7fe57f5730.tar.gz
nixos-server-5a6dd9797b67c08d58236956fbb43b7fe57f5730.zip
Merge pull request 'server1_develop' (#22) from server1_develop into server1
Reviewed-on: https://git.sils.li/vhack.eu/nixos-server/pulls/22
Reviewed-by: sils <sils@sils.li>
Diffstat (limited to 'system/services/fail2ban/default.nix')
-rw-r--r--system/services/fail2ban/default.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/system/services/fail2ban/default.nix b/system/services/fail2ban/default.nix
new file mode 100644
index 0000000..5aee097
--- /dev/null
+++ b/system/services/fail2ban/default.nix
@@ -0,0 +1,30 @@
+# vim: ts=2
+{...}: {
+  services.fail2ban = {
+    enable = true;
+    maxretry = 2; # ban after 2 failures
+    daemonConfig = ''
+      [Definition]
+      logtarget = SYSLOG
+      socket    = /run/fail2ban/fail2ban.sock
+      pidfile   = /run/fail2ban/fail2ban.pid
+      dbfile    = /srv/fail2ban/fail2ban.sqlite3
+    '';
+    bantime-increment = {
+      enable = true;
+      rndtime = "8m";
+      overalljails = true;
+      multipliers = "2 4 16 128 256";
+      maxtime = "72h";
+    };
+    jails = {
+      dovecot = ''
+        # block IPs which failed to log-in
+        # aggressive mode add blocking for aborted connections
+        enabled = true
+        filter = dovecot[mode=aggressive]
+        maxretry = 2
+      '';
+    };
+  };
+}