{ "module": "fail2ban", "version": "1", "capabilities": [ "firewall" ], "claims": [ { "name": "mesh-intrusion-prevention", "scope": "node" } ], "resources": [ { "id": "package", "type": "package", "package": "fail2ban" }, { "id": "jail-d", "type": "directory", "path": "/etc/fail2ban/jail.d", "mode": "0755" }, { "id": "action-d", "type": "directory", "path": "/etc/fail2ban/action.d", "mode": "0755" }, { "id": "jail-local", "type": "file", "path": "/etc/fail2ban/jail.local", "mode": "0644", "content": "[INCLUDES]\n\nbefore = paths-arch.conf\n\n[DEFAULT]\n\nbantime = 10m\nfindtime = 10m\nmaxretry = 5\n\nbanaction = ufw\nbanaction_allports = iptables-allports\n\n[sshd]\nenabled = true\nport = ssh\nlogpath = %(sshd_log)s\nbackend = %(sshd_backend)s\n" }, { "id": "jail-sshd", "type": "file", "path": "/etc/fail2ban/jail.d/sshd.conf", "mode": "0644", "content": "[sshd]\nenabled = true\nport = ssh\nlogpath = %(sshd_log)s\nbackend = %(sshd_backend)s\nmaxretry = 5\n" }, { "id": "jail-recidive", "type": "file", "path": "/etc/fail2ban/jail.d/recidive.conf", "mode": "0644", "content": "[recidive]\nenabled = true\nlogpath = /var/log/fail2ban.log\n# Ban in both INPUT (host services like SSH) and DOCKER-USER (container services)\nbanaction = iptables-allports-dualchain\nbantime = 1w\nfindtime = 1d\n" }, { "id": "action-dualchain", "type": "file", "path": "/etc/fail2ban/action.d/iptables-allports-dualchain.conf", "mode": "0644", "content": "# Fail2Ban action: ban in both INPUT and DOCKER-USER chains\n# Used by recidive to block repeat offenders from both host and Docker services\n\n[INCLUDES]\n\nbefore = iptables.conf\n\n[Definition]\n\ntype = allports\n\nactionstart = { -C f2b- -j >/dev/null 2>&1; } || { -N f2b- || true; -A f2b- -j ; }\n { -C INPUT -p -j f2b- >/dev/null 2>&1; } || { -I INPUT -p -j f2b-; }\n { -C DOCKER-USER -p -j f2b- >/dev/null 2>&1; } || { -I DOCKER-USER -p -j f2b-; }\n\nactionstop = -D INPUT -p -j f2b- 2>/dev/null || true\n -D DOCKER-USER -p -j f2b- 2>/dev/null || true\n -F f2b-\n -X f2b-\n\nactioncheck = -n -L f2b- >/dev/null\n\nactionban = -I f2b- 1 -s -j \n\nactionunban = -D f2b- -s -j \n\n[Init]\n\nchain = INPUT\nname = default\nprotocol = tcp\nblocktype = REJECT --reject-with icmp-port-unreachable\nreturntype = RETURN\nlockingopt = -w\niptables = iptables \n\n[Init?family=inet6]\n\nblocktype = REJECT --reject-with icmp6-port-unreachable\niptables = ip6tables \n" }, { "id": "logrotate", "type": "file", "path": "/etc/logrotate.d/fail2ban", "mode": "0644", "content": "/var/log/fail2ban.log {\n missingok\n notifempty\n postrotate\n /usr/bin/fail2ban-client flushlogs >/dev/null || true\n endscript\n}\n" }, { "id": "run", "type": "service", "unit": "fail2ban.service", "state": "running", "boot": "enabled", "restart-on": [ "jail-local", "jail-sshd", "jail-recidive", "action-dualchain" ] } ] }