LinuxCommandLibrary

nftables

TLDR

List all rules

$ sudo nft list ruleset
copy
Add table
$ sudo nft add table inet [filter]
copy
Add chain
$ sudo nft add chain inet [filter] [input] '{ type filter hook input priority 0; }'
copy
Add rule
$ sudo nft add rule inet [filter] [input] tcp dport [22] accept
copy
Delete rule
$ sudo nft delete rule inet [filter] [input] handle [5]
copy
Load rules from file
$ sudo nft -f [/etc/nftables.conf]
copy
Flush all rules
$ sudo nft flush ruleset
copy

SYNOPSIS

nft [options] [commands]

DESCRIPTION

nftables is the modern Linux firewall framework replacing iptables. It provides a single unified interface for IPv4, IPv6, ARP, and bridge filtering.
nftables uses a new syntax and improves on iptables performance and functionality.

PARAMETERS

list

List objects.
add
Add object.
delete
Delete object.
flush
Flush objects.
-f file
Read commands from file.
-i
Interactive mode.
-n
Numeric output.

RULE EXAMPLE

$ table inet filter {
    chain input {
        type filter hook input priority 0;
        ct state established,related accept
        tcp dport 22 accept
        tcp dport 80 accept
        drop
    }
}
copy

CAVEATS

Different syntax from iptables. Replaces iptables, ip6tables, arptables, ebtables. Requires kernel support.

HISTORY

nftables was developed by the Netfilter project, authored primarily by Patrick McHardy and Pablo Neira Ayuso, released in Linux kernel 3.13 (2014).

SEE ALSO

iptables(8), firewalld(1), ufw(8), netfilter(7)

Copied to clipboard