nftables and management layers
Quick answer
nftables is a Linux packet classification and filtering framework. The nft command manages its tables, chains and rules. UFW and firewalld provide higher-level management interfaces.
Decide which management layer owns the firewall policy. A direct rule edit can conflict with a higher-level manager that later regenerates its rules. Compare the intended policy with the effective ruleset through the documented interface before changing anything.
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: Stateful filtering and connection tracking.
How it works
A table groups rules; a base chain attaches to a netfilter hook and has a priority and optionally a policy. Regular chains are reached through jumps or gotos. The inet family can handle IPv4 and IPv6; ip and ip6 expressions remain address-family specific. A rule may contain matches, counters and a verdict. iptables commands may use a legacy backend or an nft compatibility backend depending on installed alternatives. UFW provides a simpler policy interface, while firewalld uses zones and policies and distinguishes runtime configuration from permanent configuration. Do not assume that nft output is an independent firewall from the front end that created it. Identify the active manager first and avoid mixing direct changes with managed rules. The sample file is an intentionally incomplete teaching ruleset, not a deployable network policy; it omits ICMP/ICMPv6 requirements and forwarding/output decisions.
Try the examples
grep -E 'table inet|hook input|ct state' teaching.nftThese are literal configuration lines; grep cannot validate nft syntax or kernel support.
Expected stdout:
table inet bm_teaching { type filter hook input priority 0; policy drop; ct state invalid drop ct state established,related accept ct state new tcp dport 443 acceptThis is a conceptual comparison, not discovery of installed firewall managers.
Expected stdout:
nft=nativeiptables=legacy-or-nft-compatufw=frontendfirewalld=runtime-and-permanentOptional check-only command in an authorized snapshot VM with nft and required netlink privileges. It does not activate the rules. Even successful validation would not make this incomplete sample safe to deploy.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Do not load a partial ruleset, flush a working firewall, or mix competing managers. IPv6 requires its own reachability considerations.
Practice
Annotate teaching.nft with its family, hook, priority, policy and state matches. Explain why it is not a complete IPv6 policy.
Related references
Study: nft, iptables, ufw, firewall-cmd. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
nftables and management layers — Knowledge Check
Apply firewall and network concepts to synthetic fixtures and VM-only scenarios.
Which family can cover IPv4 and IPv6?
What does nft -c -f do?
What can happen with iptables?
Which firewalld distinction matters for persistence?