Forrest logo
back to the nft tool

nft:tldr:3fff1

nft: Show rule handles.
$ sudo nft --handle --numeric list chain ${family} ${table} ${chain}
try on your machine

This command is using the nft command-line tool with elevated privileges (sudo) to list the rules in a specific chain within a given family, table, and chain in the nftables firewall.

Here is a breakdown of the command:

  • sudo: This command allows a user to execute a command with administrative privileges. It prompts for the user's password to confirm their authority.
  • nft: This is the command-line tool for managing and querying nftables, which is a packet filtering framework in Linux.
  • --handle: This flag instructs the nft command to display the rule handles (unique identifiers) in the output.
  • --numeric: This flag tells the nft command to display IP addresses and port numbers in numeric form rather than resolving them to hostnames or service names.
  • list chain: This is the specific action being performed, which is to list the rules in a chain.
  • ${family}: This is a placeholder for the name of the network protocol family, such as ip, ip6, inet, etc.
  • ${table}: This is a placeholder for the name of the table within the specified family.
  • ${chain}: This is a placeholder for the name of the chain within the specified table.

You would typically replace ${family}, ${table}, and ${chain} with the actual names you want to query. For example, if you want to list the rules in the filter table's INPUT chain for the IPv4 family, you would run:

sudo nft --handle --numeric list chain ip filter INPUT
This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nft tool