ufw — Ubuntu's uncomplicated firewall

Blocks via ufw(8). Unlike the table/set based backends there is no container to create — each ban prepends one or more per-IP rules, and each unban deletes them again.

[kur.sshd]
backend   = "ufw"
ports     = [ "22" ]
protocols = [ "tcp" ]

[kur.sshd.options]
kill = "conntrack"

What it creates

Per banned IP, one rule per blocked protocol, prepended so it sits above ufw's allow rules:

ufw prepend deny proto tcp from 1.2.3.4 to any port 22

The rule specs, by configuration:

Unban deletes the very same specs (ufw delete deny proto tcp from ...) — no comments or markers are used; the spec itself is the identity.

Requirements

Ports, protocols, and names

Options

| option | default | what | |--------|---------|---------------------------------------------------------------------------| | type | deny | deny silently drops; reject sends a reject back | | kill | "" | "" nothing; "ss" uses ss -K; "conntrack" uses conntrack -D |

kill

A ufw rule only stops new connections (see security). The two kill flavors, both scoped to the configured protocols and both covering IPv4 and IPv6:

Exit codes are ignored — nothing matching is not an error.

What each operation runs

| operation | commands | |------------|------------------------------------------------------------------------------| | init | ufw status \| grep -qiE "^Status:[[:space:]]*active" (fatal if inactive) | | ban | ufw prepend <type> <spec> per spec, then the kill commands if enabled | | unban | ufw delete <type> <spec> per spec | | list | no command — the kur's own ban book | | check | the same ufw status probe as init | | flush | ufw delete <type> <spec> for every banned IP's specs | | re_init | teardown (best effort), init, re-add every banned IP's rules | | teardown | ufw delete <type> <spec> for every banned IP (ban book kept for re_init) |

self_heal and reloads

check only verifies ufw is active — it does not verify the individual per-IP rules still exist. ufw disable/enable cycles are caught; a hand-deleted rule is not, and self_heal won't restore it — the kur's book and re_init are the recovery path, see the ban-time footnotes in security. (Some backends' check does verify individual rules; ufw's is only the status probe.)

Gotchas