configuration

nftables.conf — Ruleset declarations

nftables represents filtering rules as tables, chains and rules. An inet table can contain IPv4 and IPv6 rules. A regular chain has no packet hook unless reached from another chain; a base chain attaches to a hook with a type and priority. Rule order matters within chains; a base chain policy governs unmatched traffic at its end. Multiple base chains may participate at a hook. Included files and the active firewall manager determine the effective policy; do not mix independently managed rulesets. This sample has no hook and is not a firewall. nft -c -f checks a candidate without committing changes, but may need kernel access and privileges. Run only in an authorized disposable VM, never load the sample. Preserve current manager settings and a tested recovery path before a real change; do not flush a live ruleset. A successful check does not prove management access or IPv6 behavior.

Formal Syntax & Structure

linux syntaxlinux
table inet bm_demo {    chain teaching {        counter    }}

Parameters & Attributes

NameTypeDescription
tabledirective or fieldFamily and table name
chaindirective or fieldRule container
ruledirective or fieldMatch and action statements
hookdirective or fieldBase-chain attachment
policydirective or fieldBase-chain fallback

Return Value

configuration or inspection

Check status, not active packet filtering.

Working Example

Example Snippetlinux
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITcat > "$d/demo.nft" <<'EOF'table inet bm_demo {    chain teaching {        counter    }}EOFnft -c -f "$d/demo.nft"printf 'candidate checked; no rules committed\n'
Linux Reference