Nftables usage

From wikinotes
Revision as of 14:50, 13 March 2022 by Will (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Info

You can create tables/chains/rules on the commandline, but it's way more readable to write a file.
You can even split your rules withing multiple files and source them.

nft list tables                   # list tables
nft list table 'inet' 'my_table'  # list chains in 'inet' table 'my_table'

nft list ruleset                  # list all rules

nft describe <expression>         # get info about reqd types

Validating Rules

sudo nft -c -f /etc/nftables.conf

Clearing Rules

Clear all Rules.
Add this to the top of your nftables file to flush rules every time your file is loaded.

nft flush ruleset
nft flush table 'table_name'
nft delete table 'table_name'