Configuring tables

From nftables wiki
Revision as of 16:21, 13 February 2021 by Fmyhr (talk | contribs) (→‎Deleting tables: clarity)
Jump to navigation Jump to search

Some basic operations and commands that you will use to configure tables in the nftables framework.

Adding tables

% nft add table ip filter

Show/List tables

% nft list tables

Deleting tables

% nft delete table ip foo

Troubleshooting: Since Linux kernel 3.18, you can delete a table and its contents with this command. Earlier kernels require you to flush the table's contents first, otherwise you hit an error:

% nft delete table filter
<cmdline>:1:1-19: Error: Could not delete table: Device or resource busy
delete table filter
^^^^^^^^^^^^^^^^^^^

Flushing tables

You can delete all the rules that belong to this table with the following command:

% nft flush table ip filter

This removes the rules for every chain that you register in that table.

Note: nft flush table ip filter will not flush Sets defined within that table, and will cause an error if the table to be flushed does not exist and you're using Linux <4.9.0, which you can overcome by flushing the ruleset.

See also

More valuable information: