feat: an opt-in firewall derived from the manifests, cloud advanced only (0041 step 3) #59
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/keel!59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/manifest-firewall"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The firewall part of step 3 of handbook decision 0041, split from #58 and stacked on it: until #58 merges, this diff also shows its three commits; the firewall is the last one.
Scoped by the maintainer on 2026-09-30: optional and for cloud advanced only.
firewall.enabled: trueis refused unlessinstallation.mode: cloud_advanced(and an appliance is named); absent is off, and in the simple and cloud simple modes keel installs and changes no firewall rule.Why nftables
trixie's
iptablesis the nftables backend by default, and TurnKey 19 switches the alternative toiptables-legacyonly for Webmin's firewall module (itsconf/turnkey.d/webmin-fwsays "TODO: drop use of iptables-legacy and use nftables directly"); 0041 replaces thoseWEBMIN_FW_TCP_INCOMINGrules. nftables gives keel one table of its own,inet keel, replaced in one transaction, touching no iptables rule, no CrowdSec bouncer table and nothing of the operator's, andnft -cchecks a file before it is loaded. Legacy iptables and nftables are both evaluated at the input hook, so while an image still loads TurnKey'srules.v4keel's table can only narrow what gets in.The ruleset and its guards
network.overlay.wireguard); the overlay's UDP port. Always: loopback, established and related, ICMPv6, IPv4 echo, DHCPv6 and DHCPv4 client replies. Policy drop on input only.Port,ListenAddress, sshd_config.d; 22 by default) is opened.keel network confirm(0018).nft -c -f, thennft -f; a file keel did not write is never replaced.keel-firewall.service(shipped enabled,After=nftables.service,Before=network-pre.target) reloads it at boot only while the file exists.enabled: falseremoves keel's file and table.diff:derived.firewall(the file whole) andderived.firewall.loaded(the digest in the kernel table's comment, live only).Real test
In the s3-test container (TurnKey B4, legacy iptables policy ACCEPT), reached from the VM host over SSH:
firewall.enabled: trueinsimple:spec validateexit 3 with the reason.cloud_advanced: applied over an SSH session that kept running ("the session that ran apply is alive"). From the host after the change: new SSH ok, HTTP 80 (Apache, not in Core's manifest) dropped, was 200 before. Second apply0 change(s); diffderived.firewalland.loadedsame.Port 2222added to sshd_config.d: refused, "the ruleset would close SSH", nothing written.keel-firewall.serviceactive, table loaded, diff clean, SSH ok, HTTP dropped.enabled: falseover SSH: file and table removed, second applyunchanged (off), diff clean, HTTP 200 again.Test plan
set -o pipefail; coverage run -m pytest tests: 2209 passed, coverage 99 percent, new modules 100nft -c(1.1.3) inunshare -rn