summary refs log blame commit diff stats
path: root/system/services/fail2ban/default.nix
blob: 43fd67446f71cac7b6dbdd7a3cd1b821e0813d65 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                        



                                             
                                              
       





                                     







                                                              
    
{...}: {
  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    = /var/lib/fail2ban/db.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
      '';
    };
  };
}