infrastructure/modules/dgn-firewall/streams.nix
Tom Hubrecht fd0aeacff4
All checks were successful
build configuration / build_storage01 (push) Successful in 1m49s
build configuration / build_compute01 (push) Successful in 1m52s
build configuration / build_web02 (push) Successful in 2m0s
build configuration / build_vault01 (push) Successful in 2m12s
build configuration / build_web01 (push) Successful in 2m27s
lint / check (push) Successful in 29s
build configuration / build_geo02 (push) Successful in 1m28s
build configuration / build_rescue01 (push) Successful in 1m33s
build configuration / build_bridge01 (push) Successful in 1m22s
build configuration / build_geo01 (push) Successful in 1m35s
build configuration / push_to_cache_storage01 (push) Successful in 1m49s
build configuration / push_to_cache_compute01 (push) Successful in 1m52s
build configuration / push_to_cache_geo02 (push) Successful in 1m39s
build configuration / push_to_cache_web02 (push) Successful in 1m47s
build configuration / push_to_cache_rescue01 (push) Successful in 1m47s
build configuration / push_to_cache_bridge01 (push) Successful in 1m29s
build configuration / push_to_cache_web01 (push) Successful in 2m27s
build configuration / push_to_cache_geo01 (push) Successful in 1m22s
feat(firewall): Sunset fail2ban and switch to reaction
2024-09-01 22:51:56 +02:00

46 lines
920 B
Nix

let
act = a: [
"nft46"
"${a} element inet reaction ipvXbans { <ip> }"
];
journalctl = u: [
"journalctl"
"-fn0"
"-u"
"${u}.service"
];
ban = after: {
ban.cmd = act "add";
unban = {
inherit after;
cmd = act "delete";
};
};
available = {
ssh = {
cmd = journalctl "sshd";
filters = {
failedlogin = {
regex = [
"authentication failure;.*rhost=<ip>"
"Connection reset by authenticating user .* <ip>"
"Connection closed by invalid user .* <ip> port .*"
"Failed password for .* from <ip>"
"Invalid user .* from <ip> port .*"
"Unable to negotiate with <ip> port .*"
];
actions = ban "48h";
};
};
};
};
in
builtins.mapAttrs (_: builtins.foldl' (a: s: a // { ${s} = available.${s}; }) { }) {
default = [ "ssh" ];
}