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
table inet bm_demo { chain teaching { counter }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| table | directive or field | Family and table name |
| chain | directive or field | Rule container |
| rule | directive or field | Match and action statements |
| hook | directive or field | Base-chain attachment |
| policy | directive or field | Base-chain fallback |
Return Value
Check status, not active packet filtering.
Working Example
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'