Chain Syntax(nftables)

Chain Syntax(nftables)

Content #

{add | create} chain [family] table chain [{
    type type hook hook [device device] priority priority ;
    [policy policy ;]
    [comment comment ;]
}]

{delete | list | flush} chain [family] table chain

list chains [family]

delete chain [family] table handle handle

rename chain [family] table chain newname

When operating on a chain, there are six commands available:

  1. add - Add a chain to a table.
  2. create - Create a chain within a table unless a chain with the same name already

exists.

  1. delete - Delete a chain.
  2. flush - Clear all rules in a chain.
  3. list - Display all rules in a chain.
  4. rename - Change the name of a chain.

Three basic chain type #

  • filter - Used for packet filtering
  • route - Used for packet routing
  • nat - Used for Network Address Translation

Examples #

  • Add an input chain to the filter table

    nft add chain filter input { type filter hook input priority 0 \; }
    

From #