Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

nftables

Direct answer

nftables is the Linux packet filter. Rules sit in chains inside tables; a base chain is attached to a point in the packet's path (input, forward, output), and each packet is checked against the rules in order.

When to use this

Use it when a service is reachable locally and not from outside, or when deciding whether the host firewall is dropping something.

First 30 seconds

1. ss -ltn — is the service listening on that address and port?

2. nft list ruleset — which base chains hook input (or forward)? What is their policy?

3. Is there an accept for the port before any drop — in every chain on that hook?

4. Add a counter to the suspect rule, send traffic, read it again.

5. Still unclear → trace the packet with nft monitor trace.

Operational verification

packet arrives → every base chain on the hook, in priority order → rules top down, first verdict wins → no drop in any chain → accepted → service listening → reply passes as established

Evidence · next step

For Firewall → nftables, continue with the first unproven Topic check: Capture nft list ruleset with handles and identify all base chains relevant to the flow by family, hook, priority and policy. If that boundary is healthy, advance to the adjacent check: Resolve sets, maps, verdict maps, named counters and jump/goto chains that can affect the original tuple. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common interpretation traps
  • "I listed my table and the rule is not there, so it is not the firewall." Another table on the same hook may drop the packet; read nft list ruleset in full.
  • "The packet is accepted in my chain, so it gets through." A later chain on the same hook can still drop it.
  • "iptables -L is empty, so there are no rules." nftables rules do not necessarily appear there.
  • "I added the rule with nft add rule." It is gone after a reboot unless saved to the configuration loaded at boot.
  • "I flushed the ruleset over SSH." With a drop policy that locks you out; load a complete file atomically instead.
  • "The service does not answer, so the firewall drops it." Check that it is listening on that address first: ss -ltn.
  • "The rule is in input, and forwarded traffic is still blocked." Traffic through the host is handled by forward.
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux · Linux · distribution/version specific
Scope / prerequisiteUse it when a service is reachable locally and not from outside, or when deciding whether the host firewall is dropping…
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

8 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

ruleset source/manager → nft transaction → table family → base-chain hook/priority → expression/set/map match → verdict/NAT/state → packet continuation → workload

Healthy evidence: the intended manager produces the expected nft objects, the original packet matches the designed rule path and verdict, and positive/negative workload tests agree with policy intent.

Step 2 Operational verification Verify boundary

Linux packet filtering, tables/chains/rules, counters and verification of effective firewall policy.

Fast verification

  • Read the effective ruleset with nft list ruleset; do not rely only on configuration files.

- Check hook, family, chain priority and rule counters for the test packet.

- Trace or temporarily log a narrow test flow when counters do not identify the matching rule.

Step 3 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Capture nft list ruleset with handles and identify all base chains relevant to the flow by family, hook, priority and policy.

  • Resolve sets, maps, verdict maps, named counters and jump/goto chains that can affect the original tuple.
  • Use rule counters or nft monitor trace in a controlled scope, correlated with packet capture, to show the exact match/verdict path.
  • After the smallest ruleset change, read back the effective ruleset and repeat the original application test plus a negative/regression flow.

Verification chain. ruleset source/manager → nft transaction → table family → base-chain hook/priority → expression/set/map match → verdict/NAT/state → packet continuation → workload

Step 4 Specialized verification Verify boundary

Inspect the complete relevant ruleset with handles and counters, then generate a controlled packet that matches the real direction, addresses, protocol and interface. Follow ingress/forward/output and NAT hooks as required and use counter deltas or tracing to show the packet reached a rule. Correlate conntrack state when stateful policy matters. A rule being present shows configuration, not traversal; a counter increment shows rule match, not necessarily application success beyond the firewall.

Step 5 Commands Verify boundary
nft list ruleset
nft list table inet filter
nft -c -f /etc/nftables.conf
Step 6 Failure modes and next checks Narrow the fault

Suspicious evidence: rules exist in an unused family/namespace, another base chain runs earlier, set contents differ from assumptions, counters stay zero, or direct nft edits are later overwritten by a manager.

It does not show behavior outside the captured namespace, family, five-tuple, interface/direction, manager/backend, ruleset generation, conntrack/NAT state, time window or application scope. nftables evidence requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not evidence.

Step 7 Special cases and limits Narrow the fault

Packet filtering, NAT, routing and application listeners are separate layers. An accept verdict cannot repair a missing route or closed socket, and a drop counter can reflect intentionally unwanted traffic. Other managers may install higher/lower priority chains. IPv4-only rules do not cover IPv6 unless the family/design does. Keep rule ownership, hook ordering, routing, conntrack/NAT and service behavior separate.

Step 8 Common mistakes Narrow the fault
  • Loading rules without -c check first.
  • Flushing the ruleset remotely.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Read the whole ruleset: firewalld, Docker and the iptables compatibility layer create tables of their own, and a drop in any chain on the hook is final. Traffic to the host uses input; traffic through it uses forward. Rules added on the command line are gone after a reboot.

Key checks
  • nft list ruleset — everything in force, whoever wrote it.
  • nft -a list chain inet filter input — one chain with rule handles.
  • nft -c -f /etc/nftables.conf — check a file without applying it.
  • nft monitor trace — follow a packet marked with meta nftrace set 1.
  • ss -ltn — is the service listening at all?
ReferenceWhat it is2 sections · depth on demand

Core model

Read the full ruleset and identify table family, base-chain type/hook/priority/policy before interpreting rule order. Resolve named sets/maps and jumps/gotos, preserve rule handles/counters, and use tracing or targeted counters plus capture to show the original tuple rather than assuming a visually plausible rule is effective.

Mental model

nftables is the packet filtering framework in current Linux kernels and the successor to iptables. Rules are organised in tables and chains; a chain is attached to a point in the packet's path through the kernel, and each packet is checked against its rules in order.

ReferenceWhy it matters2 sections · depth on demand

When to use it

Use this Topic when the problem is in Firewalling with nftables. Use Linux Networking when the problem concerns Linux runtime, services, networking, identity, packages, storage or shell automation.

Why it matters operationally

A firewall on the host is one of the first suspects when a service is reachable locally and not from outside. With nftables the ruleset can come from several places — a configuration file, firewalld, a container runtime, the iptables compatibility layer — and the rule that drops a packet may sit in a table nobody remembered. Reading the whole ruleset and tracing a packet through it removes the guessing.

ReferenceHow it works1 section · depth on demand

How it works

Structure.

  • A table is a container with an address family: ip (IPv4), ip6, inet (both), arp, bridge or netdev.
  • A chain holds rules. A base chain is attached to a kernel hook and has a type, a priority and a default policy. Other chains are reached only by a jump from a rule.
  • A rule matches packets and ends in a verdict: accept, drop, reject, or a jump to another chain.
table inet filter {
  chain input {
    type filter hook input priority 0; policy drop;
    ct state established,related accept
    iif "lo" accept
    tcp dport { 22, 443 } accept
  }
}

Hooks — where a base chain sees packets:

HookPackets
preroutingAll incoming, before the routing decision
inputAddressed to the host itself
forwardPassing through the host
outputGenerated by the host
postroutingAll outgoing, after routing

A server's own services are governed by input; a router or container host by forward.

Evaluation. Within a chain, rules are checked top to bottom and the first verdict ends the walk; if none matches, the policy applies. Several base chains can sit on the same hook, in order of priority, and a packet accepted in one can still be dropped in a later one. A drop anywhere is final.

Connection tracking. ct state established,related accept lets replies and related traffic through, so rules only need to describe new connections.

Loading. nft -f <file> applies a ruleset atomically: all of it or none. nft -c -f <file> checks the syntax without applying. Rules entered on the command line last until reboot; persistence comes from /etc/nftables.conf and the nftables service — or from firewalld, where that manages the firewall.

Other producers of rules. firewalld, Docker, Kubernetes and the iptables-nft compatibility layer all create tables of their own. nft list ruleset shows everything in force, whoever wrote it.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

nftables evidence requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not evidence.

In depth

nftables: tables, base chains and rules

nftables replaces iptables, ip6tables, arptables and ebtables with one tool and one syntax. The nftables quick reference describes the building blocks:

  • Tables belong to a family: ip, ip6, inet (both IPv4 and IPv6), arp, bridge or netdev.
  • Base chains attach to a hook with a type (filter, nat or route), a priority and a policy (accept by default, or drop).
  • Rules combine matches and statements: accept, drop, reject, jump, goto, counter and log.
  • Sets: anonymous sets in braces, such as tcp dport { 22, 443 }, and verdict maps (vmap), which map values to verdicts.
  • Commands: nft list ruleset shows everything (-a adds rule handles). nft -f file loads a file as one batch. Rules are deleted or inserted by handle.

The nftables wiki notes that nftables predefines no chains. You create base chains only where you need them.

A host firewall in one file

host$ cat /etc/nftables.conf
flush ruleset

table inet filter {
    set mgmt_nets {
        type ipv4_addr; flags interval
        elements = { 10.99.0.0/24, 10.110.0.0/16 }
    }

    chain input {
        type filter hook input priority filter; policy drop;
        ct state established,related accept
        ct state invalid drop
        iif lo accept
        meta l4proto { icmp, ipv6-icmp } accept
        ip saddr @mgmt_nets tcp dport 22 accept
        tcp dport { 80, 443 } accept
        counter log prefix "nft-in-drop: " limit rate 5/minute
    }

    chain forward {
        type filter hook forward priority filter; policy drop;
    }
}
host$ sudo nft -c -f /etc/nftables.conf && sudo nft -f /etc/nftables.conf
host$ sudo systemctl enable nftables
host$ sudo nft -a list chain inet filter input | grep -n "dport 22"
host$ sudo nft add element inet filter mgmt_nets '{ 10.120.0.0/16 }'

Notes on the file

ElementWhy
flush ruleset at the topThe file replaces the whole ruleset in one atomic load
inet familyOne ruleset for IPv4 and IPv6
Established/related firstMost packets match early
ICMP allowedPath MTU discovery and IPv6 neighbour discovery need it
A named set for management networksExtend it without touching the rules
The log rule with a rate limitSee drops without flooding the log

Test before loading

nft -c -f checks the file without applying it. Because -f loads the file as one transaction, a syntax error leaves the old ruleset untouched. There's never a half-applied firewall.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

nftables is part of Firewall → nftables. nftables is the modern Linux netfilter rule-management framework using tables, chains, rules, sets, maps and expressions across families such as inet, ip, ip6, bridge and netdev, with atomic ruleset transactions and explicit base-chain hooks/priorities.

nftables, iptables compatibility layers, firewalld and UFW are policy/configuration interfaces that can program overlapping kernel rulesets.

Topic-specific state model. nftables is the modern Linux netfilter rule-management framework using tables, chains, rules, sets, maps and expressions across families such as inet, ip, ip6, bridge and netdev, with atomic ruleset transactions and explicit base-chain hooks/priorities.

Interpretation rule. - nft list ruleset success ≠ intended packet is permitted; it only shows ruleset visibility.

  • Rule textual order ≠ global hook order when multiple base chains have different priorities.
  • An inet table ≠ every bridge/netdev packet path is covered; family and hook placement still matter.
  • Atomic rule load success ≠ application connectivity; routing, conntrack, NAT and service state remain separate things to check.

Specialized mechanics

nftables programs Netfilter using tables, base chains attached to hooks, priorities and rules evaluated in packet context. Families such as inet can cover IPv4 and IPv6, while stateful expressions can use conntrack. Base-chain hook and priority determine where a rule runs relative to routing/NAT and other Netfilter users. User-defined chains only participate when jumped/goto from an active path. Reading rule text without hook, family and counters can therefore miss the actual packet path.

Limits and how it fails

Primary failure point. nftables evidence requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not evidence.

ReferenceConfiguration & state2 sections · depth on demand

Configuration, persistence and lifecycle

Transactional nftables updates are preferable to partially applied sequences.

Specialized lifecycle

Maintain one clear source of truth for the ruleset and load it atomically where possible. Define table/family, base-chain type/hook/priority and default policy explicitly. When mixing with firewalld, container runtimes or other managers, know which component owns which tables/chains; manual edits can be overwritten. Use sets/maps for scalable policy and validate a candidate ruleset before replacing production state. Remote firewall changes should preserve a recovery path and avoid flushing unrelated manager-owned chains.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Firewall → nftables. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://wiki.nftables.org/wiki-nftables/index.php/Main_Page · confidence 94%
2026-09-13 · vendor docnftables current

Authoritative Linux project/vendor documentation reviewed for bounded reference claims: tables/chains/rules, hooks, priorities and ruleset evaluation. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.

Basis: https://wiki.nftables.org/wiki-nftables/index.php/Main_Page · confidence 93%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
nftablesnft list rulesetnft monitor tracelinux nft firewall
Embedded reference data

Quick lookup tables

nftables operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for nftables.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statenftables is the modern Linux netfilter rule-management framework using tables, chains, rules, sets, maps and expressions across families such as inet, ip, ip6, bridge and netdev, with atomic ruleset transactions and explicit base-chain hooks/priorities.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin exact namespace + five-tuple + interfaces/direction → prove route/listener prerequisites → identify manager/backend → snapshot full ruleset + hook priorities/default policies → reproduce with counters/trace + packet capture → correlate conntrack/NAT → change one demonstrated cause → read back effective state → repeat original workload + negative regression flow.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainruleset source/manager → nft transaction → table family → base-chain hook/priority → expression/set/map match → verdict/NAT/state → packet continuation → workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundarynftables proof requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not proof.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux firewall evidence can establish this proof path: ruleset source/manager → nft transaction → table family → base-chain hook/priority → expression/set/map match → verdict/NAT/state → packet continuation → workloadUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured namespace, family, five-tuple, interface/direction, manager/backend, ruleset generation, conntrack/NAT state, time window or application scope. nftables proof requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not proof.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven firewall boundary: preserve the current ruleset/state, capture the exact packet path and rule verdict, change only the demonstrated cause through the authoritative manager, read back effective policy, then repeat the original workload and regression flows.Continue to the next unresolved boundary while preserving the original test condition.

nftables · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundarynftables
Topic pathFirewall → nftables
Runtime statenftables is the modern Linux netfilter rule-management framework using tables, chains, rules, sets, maps and expressions across families such as inet, ip, ip6, bridge and netdev, with atomic ruleset transactions and explicit base-chain hooks/priorities.
Fast checks- Capture nft list ruleset with handles and identify all base chains relevant to the flow by family, hook, priority and policy. - Resolve sets, maps, verdict maps, named counters and jump/goto chains that can affect the original tuple. - Use rule counters or nft monitor trace in a controlled scope, correlated with packet capture, to prove the exact match/verdict path. - After the smallest ruleset change, read back the effective ruleset and repeat the original application test plus a negative/regression flow.
Verification chainruleset source/manager → nft transaction → table family → base-chain hook/priority → expression/set/map match → verdict/NAT/state → packet continuation → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary.
Failure boundarynftables proof requires the original packet to be traced or otherwise correlated through the effective family/hook/priority/rule path to its verdict; parsed configuration or transaction success alone is not proof. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.

nftables · specialized operational reference

Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.

Operational boundaryTopic-specific reference
Executionfamily → hook → priority → chain/rule
OwnershipAvoid conflicts with firewalld/container managers
ProofControlled packet + rule/trace counter delta
BoundaryFirewall verdict ≠ route/listener/application result
Confirmation

Confirm action

Continue?