Using nft commands

There are two ways to use the nft utility. You can just do everything directly from the Bash shell, prefacing every action you want to perform with nft, followed by the nft subcommands. You can also use nft in interactive mode. For our present purposes, we'll just go with the Bash shell.

Let's first delete our previous configuration, and create an inet table, since we want something that works for both IPv4 and IPv6. We'll want to give it a somewhat descriptive name, so let's call it ubuntu_filter:

sudo nft delete table inet filtersudo nft list tablessudo nft add table inet ubuntu_filtersudo nft list tables

Next, we'll add an input filter chain to the table that we just created. (Note that since we're doing this from the ...

Get Mastering Linux Security and Hardening now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.