Safe firewall changes
Quick answer
A safe firewall change has a known owner, a reviewed candidate policy, independent recovery access, verification steps and a rollback plan. Syntax validation alone cannot prove that administration will remain reachable.
An existing administrative session surviving a change does not prove new sessions are allowed. Use independent recovery access in a disposable lab and check a new authorized connection plus a deliberately denied one before accepting the change.
Prepare the practice environment
Run python3 lab-fixtures/firewalls/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not modify firewall, interfaces or routing. The teaching ruleset must never be loaded. Review the lab guide.
Prerequisites
Review: nftables and management layers.
How it works
Before an authorized VM change, identify the manager, interfaces, allowed services, existing sessions, IPv4/IPv6 paths and recovery console. Preserve a verified known-good configuration in a protected location, confirm how the active manager restores it and arrange a timed rollback through approved procedures. Review candidate changes and run the tool’s non-applying validation; netlink access may be required even for nft check mode. Verify a new management connection and expected permitted and denied traffic from authorized test endpoints before persisting the policy. Existing SSH can survive an established rule while new logins fail. Never use a remote-only session as the recovery method. The included JSON model checks a change plan and exercises the decision to reject unsafe changes; it cannot confirm real connectivity or automatically roll back an actual firewall.
Try the examples
All required flags are set in this fictional plan; this is not approval to deploy.
Expected stdout:
plan ready for reviewThe helper reports two absent prerequisites and does not change any policy.
Expected stdout:
blocked: console, new_login{ diff -u plan-safe.json plan-unsafe.json || test "$?" -eq 1; } | grep '^+' | grep 'false'diff exit 1 means different files, so the group explicitly accepts it but not other failure statuses. The lines show missing prerequisites.
Expected stdout:
+ "console": false,+ "new_login": false,Common mistakes
Never persist an unverified candidate merely because a syntax check passed or an old session stayed connected.
Practice
Compare the safe and unsafe JSON plans. Write a review checklist that includes a separate console, verified backup, new connection and rollback trigger.
Related references
Study: nft. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Safe firewall changes — Knowledge Check
Apply firewall and network concepts to synthetic fixtures and VM-only scenarios.
What is needed before a remote firewall change?
Does a successful syntax check prove reachability?
Why test a new login?
When should persistence be considered?