{
    "mode": "man",
    "parameter": "NFT",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/NFT/8/json",
    "generated": "2026-06-14T07:25:19Z",
    "synopsis": "nft [ -nNscaeSupyjt ] [ -I directory ] [ -f filename | -i | cmd ...]",
    "sections": {
        "NAME": {
            "content": "nft - Administration tool of the nftables framework for packet filtering and classification\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "nft [ -nNscaeSupyjt ] [ -I directory ] [ -f filename | -i | cmd ...]",
            "subsections": [
                {
                    "name": "nft -h",
                    "content": ""
                },
                {
                    "name": "nft -v",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "nft is the command line tool used to set up, maintain and inspect packet filtering and\nclassification rules in the Linux kernel, in the nftables framework. The Linux kernel\nsubsystem is known as nftables, and ‘nf’ stands for Netfilter.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "The command accepts several different options which are documented here in groups for better\nunderstanding of their meaning. You can get information about options by running nft --help.\n",
            "subsections": [
                {
                    "name": "General options:",
                    "content": ""
                },
                {
                    "name": "-h --help",
                    "content": "Show help message and all options.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-v --version",
                    "content": "Show version.\n",
                    "flag": "-v",
                    "long": "--version"
                },
                {
                    "name": "-V",
                    "content": "Show long version information, including compile-time configuration.\n",
                    "flag": "-V"
                },
                {
                    "name": "Ruleset input handling options that specify to how to load rulesets:",
                    "content": ""
                },
                {
                    "name": "-f --file",
                    "content": "Read input from filename. If filename is -, read from stdin.\n",
                    "flag": "-f",
                    "long": "--file"
                },
                {
                    "name": "-D --define",
                    "content": "Define a variable. You can only combine this option with -f.\n",
                    "flag": "-D",
                    "long": "--define"
                },
                {
                    "name": "-i --interactive",
                    "content": "Read input from an interactive readline CLI. You can use quit to exit, or use the EOF\nmarker, normally this is CTRL-D.\n",
                    "flag": "-i",
                    "long": "--interactive"
                },
                {
                    "name": "-I --includepath",
                    "content": "Add the directory directory to the list of directories to be searched for included files.\nThis option may be specified multiple times.\n",
                    "flag": "-I",
                    "long": "--includepath"
                },
                {
                    "name": "-c --check",
                    "content": "Check commands validity without actually applying the changes.\n",
                    "flag": "-c",
                    "long": "--check"
                },
                {
                    "name": "-o --optimize",
                    "content": "Optimize your ruleset. You can combine this option with -c to inspect the proposed\noptimizations.\n",
                    "flag": "-o",
                    "long": "--optimize"
                },
                {
                    "name": "Ruleset list output formatting that modify the output of the list ruleset command:",
                    "content": ""
                },
                {
                    "name": "-a --handle",
                    "content": "Show object handles in output.\n",
                    "flag": "-a",
                    "long": "--handle"
                },
                {
                    "name": "-s --stateless",
                    "content": "Omit stateful information of rules and stateful objects.\n",
                    "flag": "-s",
                    "long": "--stateless"
                },
                {
                    "name": "-t --terse",
                    "content": "Omit contents of sets from output.\n",
                    "flag": "-t",
                    "long": "--terse"
                },
                {
                    "name": "-S --service",
                    "content": "Translate ports to service names as defined by /etc/services.\n",
                    "flag": "-S",
                    "long": "--service"
                },
                {
                    "name": "-N --reversedns",
                    "content": "Translate IP address to names via reverse DNS lookup. This may slow down your listing\nsince it generates network traffic.\n",
                    "flag": "-N",
                    "long": "--reversedns"
                },
                {
                    "name": "-u --guid",
                    "content": "Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group.\n",
                    "flag": "-u",
                    "long": "--guid"
                },
                {
                    "name": "-n --numeric",
                    "content": "Print fully numerical output.\n",
                    "flag": "-n",
                    "long": "--numeric"
                },
                {
                    "name": "-y --numeric-priority",
                    "content": "Display base chain priority numerically.\n",
                    "flag": "-y",
                    "long": "--numeric-priority"
                },
                {
                    "name": "-p --numeric-protocol",
                    "content": "Display layer 4 protocol numerically.\n",
                    "flag": "-p",
                    "long": "--numeric-protocol"
                },
                {
                    "name": "-T --numeric-time",
                    "content": "Show time, day and hour values in numeric format.\n",
                    "flag": "-T",
                    "long": "--numeric-time"
                },
                {
                    "name": "Command output formatting:",
                    "content": ""
                },
                {
                    "name": "-e --echo",
                    "content": "When inserting items into the ruleset using add, insert or replace commands, print\nnotifications just like nft monitor.\n",
                    "flag": "-e",
                    "long": "--echo"
                },
                {
                    "name": "-j --json",
                    "content": "Format output in JSON. See libnftables-json(5) for a schema description.\n",
                    "flag": "-j",
                    "long": "--json"
                },
                {
                    "name": "-d --debug",
                    "content": "Enable debugging output. The debug level can be any of scanner, parser, eval, netlink,\nmnl, proto-ctx, segtree, all. You can combine more than one by separating by the ,\nsymbol, for example -d eval,mnl.\n",
                    "flag": "-d",
                    "long": "--debug"
                }
            ]
        },
        "INPUT FILE FORMATS": {
            "content": "LEXICAL CONVENTIONS\nInput is parsed line-wise. When the last character of a line, just before the newline\ncharacter, is a non-quoted backslash (\\), the next line is treated as a continuation.\nMultiple commands on the same line can be separated using a semicolon (;).\n\nA hash sign (#) begins a comment. All following characters on the same line are ignored.\n\nIdentifiers begin with an alphabetic character (a-z,A-Z), followed by zero or more\nalphanumeric characters (a-z,A-Z,0-9) and the characters slash (/), backslash (\\), underscore\n() and dot (.). Identifiers using different characters or clashing with a keyword need to be\nenclosed in double quotes (\").\n\nINCLUDE FILES\ninclude filename\n\nOther files can be included by using the include statement. The directories to be searched\nfor include files can be specified using the -I/--includepath option. You can override this\nbehaviour either by prepending ‘./’ to your path to force inclusion of files located in the\ncurrent working directory (i.e. relative path) or / for file location expressed as an\nabsolute path.\n\nIf -I/--includepath is not specified, then nft relies on the default directory that is\nspecified at compile time. You can retrieve this default directory via the -h/--help option.\n\nInclude statements support the usual shell wildcard symbols (,?,[]). Having no matches for an",
            "subsections": [
                {
                    "name": "include statement is not an error, if wildcard symbols are used in the include statement.",
                    "content": ""
                },
                {
                    "name": "This allows having potentially empty include directories for statements like include",
                    "content": "\"/etc/firewall/rules/\". The wildcard matches are loaded in alphabetical order. Files\nbeginning with dot (.) are not matched by include statements.\n\nSYMBOLIC VARIABLES\ndefine variable = expr\nundefine variable\nredefine variable = expr\n$variable\n\nSymbolic variables can be defined using the define statement. Variable references are\nexpressions and can be used to initialize other variables. The scope of a definition is the\ncurrent block and all blocks contained within. Symbolic variables can be undefined using the\nundefine statement, and modified using the redefine statement.\n\nUsing symbolic variables.\n\ndefine intif1 = eth0\ndefine intif2 = eth1\ndefine intifs = { $intif1, $intif2 }\nredefine intif2 = wlan0\nundefine intif2\n\nfilter input iif $intifs accept\n\n"
                }
            ]
        },
        "ADDRESS FAMILIES": {
            "content": "Address families determine the type of packets which are processed. For each address family,\nthe kernel contains so called hooks at specific stages of the packet processing paths, which\ninvoke nftables if rules for these hooks exist.\n\n\nip       IPv4 address family.\n\nip6      IPv6 address family.\n\ninet     Internet (IPv4/IPv6) address\nfamily.\n\narp      ARP address family, handling IPv4\nARP packets.\n\nbridge   Bridge address family, handling\npackets which traverse a bridge\ndevice.\n\nnetdev   Netdev address family, handling\npackets on ingress and egress.\n\n\nAll nftables objects exist in address family specific namespaces, therefore all identifiers\ninclude an address family. If an identifier is specified without an address family, the ip\nfamily is used by default.\n\nIPV4/IPV6/INET ADDRESS FAMILIES\nThe IPv4/IPv6/Inet address families handle IPv4, IPv6 or both types of packets. They contain\nfive hooks at different packet processing stages in the network stack.\n",
            "subsections": [
                {
                    "name": "Table 1. IPv4/IPv6/Inet address family hooks",
                    "content": "┌────────────┬───────────────────────────────────┐\n│Hook        │ Description                       │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│prerouting  │ All packets entering the system   │\n│            │ are processed by the prerouting   │\n│            │ hook. It is invoked before the    │\n│            │ routing process and is used for   │\n│            │ early filtering or changing       │\n│            │ packet attributes that affect     │\n│            │ routing.                          │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│input       │ Packets delivered to the local    │\n│            │ system are processed by the input │\n│            │ hook.                             │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│forward     │ Packets forwarded to a different  │\n│            │ host are processed by the forward │\n│            │ hook.                             │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│output      │ Packets sent by local processes   │\n│            │ are processed by the output hook. │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│postrouting │ All packets leaving the system    │\n│            │ are processed by the postrouting  │\n│            │ hook.                             │\n├────────────┼───────────────────────────────────┤\n│            │                                   │\n│ingress     │ All packets entering the system   │\n│            │ are processed by this hook. It is │\n│            │ invoked before layer 3 protocol   │\n│            │ handlers, hence before the        │\n│            │ prerouting hook, and it can be    │\n│            │ used for filtering and policing.  │\n│            │ Ingress is only available for     │\n│            │ Inet family (since Linux kernel   │\n│            │ 5.10).                            │\n└────────────┴───────────────────────────────────┘\n\nARP ADDRESS FAMILY\nThe ARP address family handles ARP packets received and sent by the system. It is commonly\nused to mangle ARP packets for clustering.\n"
                },
                {
                    "name": "Table 2. ARP address family hooks",
                    "content": "┌───────┬───────────────────────────────────┐\n│Hook   │ Description                       │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│input  │ Packets delivered to the local    │\n│       │ system are processed by the input │\n│       │ hook.                             │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│output │ Packets send by the local system  │\n│       │ are processed by the output hook. │\n└───────┴───────────────────────────────────┘\n\nBRIDGE ADDRESS FAMILY\nThe bridge address family handles Ethernet packets traversing bridge devices.\n\nThe list of supported hooks is identical to IPv4/IPv6/Inet address families above.\n\nNETDEV ADDRESS FAMILY\nThe Netdev address family handles packets from the device ingress and egress path. This\nfamily allows you to filter packets of any ethertype such as ARP, VLAN 802.1q, VLAN 802.1ad\n(Q-in-Q) as well as IPv4 and IPv6 packets.\n"
                },
                {
                    "name": "Table 3. Netdev address family hooks",
                    "content": "┌────────┬───────────────────────────────────┐\n│Hook    │ Description                       │\n├────────┼───────────────────────────────────┤\n│        │                                   │\n│ingress │ All packets entering the system   │\n│        │ are processed by this hook. It is │\n│        │ invoked after the network taps    │\n│        │ (ie. tcpdump), right after tc     │\n│        │ ingress and before layer 3        │\n│        │ protocol handlers, it can be used │\n│        │ for early filtering and policing. │\n├────────┼───────────────────────────────────┤\n│        │                                   │\n│egress  │ All packets leaving the system    │\n│        │ are processed by this hook. It is │\n│        │ invoked after layer 3 protocol    │\n│        │ handlers and before tc egress. It │\n│        │ can be used for late filtering    │\n│        │ and policing.                     │\n└────────┴───────────────────────────────────┘\n\nTunneled packets (such as vxlan) are processed by netdev family hooks both in decapsulated\nand encapsulated (tunneled) form. So a packet can be filtered on the overlay network as well\nas on the underlying network.\n\nNote that the order of netfilter and tc is mirrored on ingress versus egress. This ensures\nsymmetry for NAT and other packet mangling.\n\nIngress packets which are redirected out some other interface are only processed by netfilter\non egress if they have passed through netfilter ingress processing before. Thus, ingress\npackets which are redirected by tc are not subjected to netfilter. But they are if they are\nredirected by netfilter on ingress. Conceptually, tc and netfilter can be thought of as\nlayers, with netfilter layered above tc: If the packet hasn’t been passed up from the tc\nlayer to the netfilter layer, it’s not subjected to netfilter on egress.\n"
                }
            ]
        },
        "RULESET": {
            "content": "{list | flush} ruleset [family]\n\nThe ruleset keyword is used to identify the whole set of tables, chains, etc. currently in\nplace in kernel. The following ruleset commands exist:\n\n\nlist    Print the ruleset in\nhuman-readable format.\n\nflush   Clear the whole ruleset. Note\nthat, unlike iptables, this will\nremove all tables and whatever\nthey contain, effectively leading\nto an empty ruleset - no packet\nfiltering will happen anymore, so\nthe kernel accepts any valid\npacket it receives.\n\n\nIt is possible to limit list and flush to a specific address family only. For a list of valid\nfamily names, see the section called “ADDRESS FAMILIES” above.\n\nBy design, list ruleset command output may be used as input to nft -f. Effectively, this is\nthe nft-equivalent of iptables-save and iptables-restore.\n",
            "subsections": []
        },
        "TABLES": {
            "content": "{add | create} table [family] table [ {comment comment ;} { flags 'flags ; }]\n{delete | list | flush} table [family] table\nlist tables [family]\ndelete table [family] handle handle\n\nTables are containers for chains, sets and stateful objects. They are identified by their\naddress family and their name. The address family must be one of ip, ip6, inet, arp, bridge,\nnetdev. The inet address family is a dummy family which is used to create hybrid IPv4/IPv6\ntables. The meta expression nfproto keyword can be used to test which family (ipv4 or ipv6)\ncontext the packet is being processed in. When no address family is specified, ip is used by\ndefault. The only difference between add and create is that the former will not return an\nerror if the specified table already exists while create will return an error.\n",
            "subsections": [
                {
                    "name": "Table 4. Table flags",
                    "content": "┌────────┬─────────────────────────────────┐\n│Flag    │ Description                     │\n├────────┼─────────────────────────────────┤\n│        │                                 │\n│dormant │ table is not evaluated any more │\n│        │ (base chains are unregistered). │\n└────────┴─────────────────────────────────┘\n\nAdd, change, delete a table.\n\n# start nft in interactive mode\nnft --interactive\n\n# create a new table.\ncreate table inet mytable\n\n# add a new base chain: get input packets\nadd chain inet mytable myin { type filter hook input priority filter; }\n\n# add a single counter to the chain\nadd rule inet mytable myin counter\n\n# disable the table temporarily -- rules are not evaluated anymore\nadd table inet mytable { flags dormant; }\n\n# make table active again:\nadd table inet mytable\n\n\n\nadd      Add a new table for the given\nfamily with the given name.\n\ndelete   Delete the specified table.\n\nlist     List all chains and rules of the\nspecified table.\n\nflush    Flush all chains and rules of the\nspecified table.\n\n"
                }
            ]
        },
        "CHAINS": {
            "content": "{add | create} chain [family] table chain [{ type type hook hook [device device] priority priority ; [policy policy ;] [comment comment ;] }]\n{delete | list | flush} chain ['family] table chain\nlist chains [family]\ndelete chain [family] table handle handle\nrename chain [family] table chain newname\n\nChains are containers for rules. They exist in two kinds, base chains and regular chains. A\nbase chain is an entry point for packets from the networking stack, a regular chain may be\nused as jump target and is used for better rule organization.\n\n\nadd      Add a new chain in the specified\ntable. When a hook and priority\nvalue are specified, the chain is\ncreated as a base chain and\nhooked up to the networking\nstack.\n\ncreate   Similar to the add command, but\nreturns an error if the chain\nalready exists.\n\ndelete   Delete the specified chain. The\nchain must not contain any rules\nor be used as jump target.\n\nrename   Rename the specified chain.\n\nlist     List all rules of the specified\nchain.\n\nflush    Flush all rules of the specified\nchain.\n\n\nFor base chains, type, hook and priority parameters are mandatory.\n",
            "subsections": [
                {
                    "name": "Table 5. Supported chain types",
                    "content": "┌───────┬───────────────┬─────────────────────┬──────────────────────┐\n│Type   │ Families      │ Hooks               │ Description          │\n├───────┼───────────────┼─────────────────────┼──────────────────────┤\n│       │               │                     │                      │\n│filter │ all           │ all                 │ Standard chain type  │\n│       │               │                     │ to use in doubt.     │\n├───────┼───────────────┼─────────────────────┼──────────────────────┤\n│       │               │                     │                      │\n│nat    │ ip, ip6, inet │ prerouting, input,  │ Chains of this type  │\n│       │               │ output, postrouting │ perform Native       │\n│       │               │                     │ Address Translation  │\n│       │               │                     │ based on conntrack   │\n│       │               │                     │ entries. Only the    │\n│       │               │                     │ first packet of a    │\n│       │               │                     │ connection actually  │\n│       │               │                     │ traverses this chain │\n│       │               │                     │ - its rules usually  │\n│       │               │                     │ define details of    │\n│       │               │                     │ the created          │\n│       │               │                     │ conntrack entry (NAT │\n│       │               │                     │ statements for       │\n│       │               │                     │ instance).           │\n├───────┼───────────────┼─────────────────────┼──────────────────────┤\n│       │               │                     │                      │\n│route  │ ip, ip6       │ output              │ If a packet has      │\n│       │               │                     │ traversed a chain of │\n│       │               │                     │ this type and is     │\n│       │               │                     │ about to be          │\n│       │               │                     │ accepted, a new      │\n│       │               │                     │ route lookup is      │\n│       │               │                     │ performed if         │\n│       │               │                     │ relevant parts of    │\n│       │               │                     │ the IP header have   │\n│       │               │                     │ changed. This allows │\n│       │               │                     │ to e.g. implement    │\n│       │               │                     │ policy routing       │\n│       │               │                     │ selectors in         │\n│       │               │                     │ nftables.            │\n└───────┴───────────────┴─────────────────────┴──────────────────────┘\n\nApart from the special cases illustrated above (e.g. nat type not supporting forward hook or\nroute type only supporting output hook), there are three further quirks worth noticing:\n\n•   The netdev family supports merely two combinations, namely filter type with ingress hook\nand filter type with egress hook. Base chains in this family also require the device\nparameter to be present since they exist per interface only.\n\n•   The arp family supports only the input and output hooks, both in chains of type filter.\n\n•   The inet family also supports the ingress hook (since Linux kernel 5.10), to filter IPv4\nand IPv6 packet at the same location as the netdev ingress hook. This inet hook allows\nyou to share sets and maps between the usual prerouting, input, forward, output,\npostrouting and this ingress hook.\n\nThe priority parameter accepts a signed integer value or a standard priority name which\nspecifies the order in which chains with the same hook value are traversed. The ordering is\nascending, i.e. lower priority values have precedence over higher ones.\n\nStandard priority values can be replaced with easily memorizable names. Not all names make\nsense in every family with every hook (see the compatibility matrices below) but their\nnumerical value can still be used for prioritizing chains.\n\nThese names and values are defined and made available based on what priorities are used by\nxtables when registering their default chains.\n\nMost of the families use the same values, but bridge uses different ones from the others. See\nthe following tables that describe the values and compatibility.\n"
                },
                {
                    "name": "Table 6. Standard priority names, family and hook compatibility matrix",
                    "content": "┌─────────┬───────┬─────────────────────┬─────────────┐\n│Name     │ Value │ Families            │ Hooks       │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│raw      │ -300  │ ip, ip6, inet       │ all         │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│mangle   │ -150  │ ip, ip6, inet       │ all         │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│dstnat   │ -100  │ ip, ip6, inet       │ prerouting  │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│filter   │ 0     │ ip, ip6, inet, arp, │ all         │\n│         │       │ netdev              │             │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│security │ 50    │ ip, ip6, inet       │ all         │\n├─────────┼───────┼─────────────────────┼─────────────┤\n│         │       │                     │             │\n│srcnat   │ 100   │ ip, ip6, inet       │ postrouting │\n└─────────┴───────┴─────────────────────┴─────────────┘\n"
                },
                {
                    "name": "Table 7. Standard priority names and hook compatibility for the bridge family",
                    "content": "┌───────┬───────┬─────────────┐\n│       │       │             │\n│Name   │ Value │ Hooks       │\n├───────┼───────┼─────────────┤\n│       │       │             │\n│dstnat │ -300  │ prerouting  │\n├───────┼───────┼─────────────┤\n│       │       │             │\n│filter │ -200  │ all         │\n├───────┼───────┼─────────────┤\n│       │       │             │\n│out    │ 100   │ output      │\n├───────┼───────┼─────────────┤\n│       │       │             │\n│srcnat │ 300   │ postrouting │\n└───────┴───────┴─────────────┘\n\nBasic arithmetic expressions (addition and subtraction) can also be achieved with these\nstandard names to ease relative prioritizing, e.g. mangle - 5 stands for -155. Values will\nalso be printed like this until the value is not further than 10 from the standard value.\n\nBase chains also allow to set the chain’s policy, i.e. what happens to packets not explicitly\naccepted or refused in contained rules. Supported policy values are accept (which is the\ndefault) or drop.\n"
                }
            ]
        },
        "RULES": {
            "content": "{add | insert} rule [family] table chain [handle handle | index index] statement ... [comment comment]\nreplace rule [family] table chain handle handle statement ... [comment comment]\ndelete rule [family] table chain handle handle\n\nRules are added to chains in the given table. If the family is not specified, the ip family\nis used. Rules are constructed from two kinds of components according to a set of grammatical\nrules: expressions and statements.\n\nThe add and insert commands support an optional location specifier, which is either a handle\nor the index (starting at zero) of an existing rule. Internally, rule locations are always\nidentified by handle and the translation from index happens in userspace. This has two\npotential implications in case a concurrent ruleset change happens after the translation was\ndone: The effective rule index might change if a rule was inserted or deleted before the\nreferred one. If the referred rule was deleted, the command is rejected by the kernel just as\nif an invalid handle was given.\n\nA comment is a single word or a double-quoted (\") multi-word string which can be used to make\nnotes regarding the actual rule. Note: If you use bash for adding rules, you have to escape\nthe quotation marks, e.g. \\\"enable ssh for servers\\\".\n\n\nadd       Add a new rule described by the\nlist of statements. The rule is\nappended to the given chain\nunless a location is specified,\nin which case the rule is\ninserted after the specified\nrule.\n\ninsert    Same as add except the rule is\ninserted at the beginning of the\nchain or before the specified\nrule.\n\nreplace   Similar to add, but the rule\nreplaces the specified rule.\n\ndelete    Delete the specified rule.\n\n\nadd a rule to ip table output chain.\n\nnft add rule filter output ip daddr 192.168.0.0/24 accept # 'ip filter' is assumed\n# same command, slightly more verbose\nnft add rule ip filter output ip daddr 192.168.0.0/24 accept\n\ndelete rule from inet table.\n\n# nft -a list ruleset\ntable inet filter {\nchain input {\ntype filter hook input priority filter; policy accept;\nct state established,related accept # handle 4\nip saddr 10.1.1.1 tcp dport ssh accept # handle 5\n...\n# delete the rule with handle 5\nnft delete rule inet filter input handle 5\n\n",
            "subsections": []
        },
        "SETS": {
            "content": "nftables offers two kinds of set concepts. Anonymous sets are sets that have no specific\nname. The set members are enclosed in curly braces, with commas to separate elements when\ncreating the rule the set is used in. Once that rule is removed, the set is removed as well.\nThey cannot be updated, i.e. once an anonymous set is declared it cannot be changed anymore\nexcept by removing/altering the rule that uses the anonymous set.\n\nUsing anonymous sets to accept particular subnets and ports.\n\nnft add rule filter input ip saddr { 10.0.0.0/8, 192.168.0.0/16 } tcp dport { 22, 443 } accept\n\nNamed sets are sets that need to be defined first before they can be referenced in rules.\nUnlike anonymous sets, elements can be added to or removed from a named set at any time. Sets\nare referenced from rules using an @ prefixed to the sets name.\n\nUsing named sets to accept addresses and ports.\n\nnft add rule filter input ip saddr @allowedhosts tcp dport @allowedports accept\n\nThe sets allowedhosts and allowedports need to be created first. The next section describes\nnft set syntax in more detail.\n\nadd set [family] table set { type type | typeof expression ; [flags flags ;] [timeout timeout ;] [gc-interval gc-interval ;] [elements = { element[, ...] } ;] [size size ;] [comment comment ;] [policy 'policy ;] [auto-merge ;] }\n{delete | list | flush} set [family] table set\nlist sets [family]\ndelete set [family] table handle handle\n{add | delete} element [family] table set { element[, ...] }\n\nSets are element containers of a user-defined data type, they are uniquely identified by a\nuser-defined name and attached to tables. Their behaviour can be tuned with the flags that\ncan be specified at set creation time.\n\n\nadd      Add a new set in the specified\ntable. See the Set specification\ntable below for more information\nabout how to specify properties\nof a set.\n\ndelete   Delete the specified set.\n\nlist     Display the elements in the\nspecified set.\n\nflush    Remove all elements from the\nspecified set.\n\n",
            "subsections": [
                {
                    "name": "Table 8. Set specifications",
                    "content": "┌────────────┬───────────────────────────┬───────────────────────────┐\n│Keyword     │ Description               │ Type                      │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│type        │ data type of set elements │ string: ipv4addr,        │\n│            │                           │ ipv6addr, etheraddr,    │\n│            │                           │ inetproto, inetservice, │\n│            │                           │ mark                      │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│typeof      │ data type of set element  │ expression to derive the  │\n│            │                           │ data type from            │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│flags       │ set flags                 │ string: constant,         │\n│            │                           │ dynamic, interval,        │\n│            │                           │ timeout                   │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│timeout     │ time an element stays in  │ string, decimal followed  │\n│            │ the set, mandatory if set │ by unit. Units are: d, h, │\n│            │ is added to from the      │ m, s                      │\n│            │ packet path (ruleset)     │                           │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│gc-interval │ garbage collection        │ string, decimal followed  │\n│            │ interval, only available  │ by unit. Units are: d, h, │\n│            │ when timeout or flag      │ m, s                      │\n│            │ timeout are active        │                           │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│elements    │ elements contained by the │ set data type             │\n│            │ set                       │                           │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│size        │ maximum number of         │ unsigned integer (64 bit) │\n│            │ elements in the set,      │                           │\n│            │ mandatory if set is added │                           │\n│            │ to from the packet path   │                           │\n│            │ (ruleset)                 │                           │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│policy      │ set policy                │ string: performance       │\n│            │                           │ [default], memory         │\n├────────────┼───────────────────────────┼───────────────────────────┤\n│            │                           │                           │\n│auto-merge  │ automatic merge of        │                           │\n│            │ adjacent/overlapping set  │                           │\n│            │ elements (only for        │                           │\n│            │ interval sets)            │                           │\n└────────────┴───────────────────────────┴───────────────────────────┘\n"
                }
            ]
        },
        "MAPS": {
            "content": "add map [family] table map { type type | typeof expression [flags flags ;] [elements = { element[, ...] } ;] [size size ;] [comment comment ;] [policy 'policy ;] }\n{delete | list | flush} map [family] table map\nlist maps [family]\n\nMaps store data based on some specific key used as input. They are uniquely identified by a\nuser-defined name and attached to tables.\n\n\nadd              Add a new map in the specified\ntable.\n\ndelete           Delete the specified map.\n\n\n\nlist             Display the elements in the\nspecified map.\n\nflush            Remove all elements from the\nspecified map.\n\nadd element      Comma-separated list of elements\nto add into the specified map.\n\ndelete element   Comma-separated list of element\nkeys to delete from the specified\nmap.\n\n",
            "subsections": [
                {
                    "name": "Table 9. Map specifications",
                    "content": "┌─────────┬───────────────────────────┬───────────────────────────┐\n│Keyword  │ Description               │ Type                      │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│type     │ data type of map elements │ string: ipv4addr,        │\n│         │                           │ ipv6addr, etheraddr,    │\n│         │                           │ inetproto, inetservice, │\n│         │                           │ mark, counter, quota.     │\n│         │                           │ Counter and quota can’t   │\n│         │                           │ be used as keys           │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│typeof   │ data type of set element  │ expression to derive the  │\n│         │                           │ data type from            │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│flags    │ map flags                 │ string: constant,         │\n│         │                           │ interval                  │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│elements │ elements contained by the │ map data type             │\n│         │ map                       │                           │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│size     │ maximum number of         │ unsigned integer (64 bit) │\n│         │ elements in the map       │                           │\n├─────────┼───────────────────────────┼───────────────────────────┤\n│         │                           │                           │\n│policy   │ map policy                │ string: performance       │\n│         │                           │ [default], memory         │\n└─────────┴───────────────────────────┴───────────────────────────┘\n"
                }
            ]
        },
        "ELEMENTS": {
            "content": "{add | create | delete | get } element [family] table set { ELEMENT[, ...] }\n\nELEMENT := keyexpression OPTIONS [: valueexpression]\nOPTIONS := [timeout TIMESPEC] [expires TIMESPEC] [comment string]\nTIMESPEC := [numd][numh][numm][num[s]]\n\nElement-related commands allow to change contents of named sets and maps. keyexpression is\ntypically a value matching the set type. valueexpression is not allowed in sets but\nmandatory when adding to maps, where it matches the data part in its type definition. When\ndeleting from maps, it may be specified but is optional as keyexpression uniquely identifies\nthe element.\n\ncreate command is similar to add with the exception that none of the listed elements may\nalready exist.\n\nget command is useful to check if an element is contained in a set which may be non-trivial\nin very large and/or interval sets. In the latter case, the containing interval is returned\ninstead of just the element itself.\n",
            "subsections": [
                {
                    "name": "Table 10. Element options",
                    "content": "┌────────┬──────────────────────────────────┐\n│Option  │ Description                      │\n├────────┼──────────────────────────────────┤\n│        │                                  │\n│timeout │ timeout value for sets/maps with │\n│        │ flag timeout                     │\n├────────┼──────────────────────────────────┤\n│        │                                  │\n│expires │ the time until given element     │\n│        │ expires, useful for ruleset      │\n│        │ replication only                 │\n├────────┼──────────────────────────────────┤\n│        │                                  │\n│comment │ per element comment field        │\n└────────┴──────────────────────────────────┘\n"
                }
            ]
        },
        "FLOWTABLES": {
            "content": "{add | create} flowtable [family] table flowtable { hook hook priority priority ; devices = { device[, ...] } ; }\nlist flowtables [family]\n{delete | list} flowtable [family] table flowtable\ndelete flowtable [family] table handle handle\n\nFlowtables allow you to accelerate packet forwarding in software. Flowtables entries are\nrepresented through a tuple that is composed of the input interface, source and destination\naddress, source and destination port; and layer 3/4 protocols. Each entry also caches the\ndestination interface and the gateway address - to update the destination link-layer address\n- to forward packets. The ttl and hoplimit fields are also decremented. Hence, flowtables\nprovides an alternative path that allow packets to bypass the classic forwarding path.\nFlowtables reside in the ingress hook that is located before the prerouting hook. You can\nselect which flows you want to offload through the flow expression from the forward chain.\nFlowtables are identified by their address family and their name. The address family must be\none of ip, ip6, or inet. The inet address family is a dummy family which is used to create\nhybrid IPv4/IPv6 tables. When no address family is specified, ip is used by default.\n\nThe priority can be a signed integer or filter which stands for 0. Addition and subtraction\ncan be used to set relative priority, e.g. filter + 5 equals to 5.\n\n\nadd      Add a new flowtable for the given\nfamily with the given name.\n\ndelete   Delete the specified flowtable.\n\nlist     List all flowtables.\n\n",
            "subsections": []
        },
        "LISTING": {
            "content": "list { secmarks | synproxys | flow tables | meters | hooks } [family]\nlist { secmarks | synproxys | flow tables | meters | hooks } table [family] table\nlist ct { timeout | expectation | helper | helpers } table [family] table\n\nInspect configured objects. list hooks shows the full hook pipeline, including those\nregistered by kernel modules, such as nfconntrack.\n",
            "subsections": []
        },
        "STATEFUL OBJECTS": {
            "content": "{add | delete | list | reset} type [family] table object\ndelete type [family] table handle handle\nlist counters [family]\nlist quotas [family]\nlist limits [family]\n\nStateful objects are attached to tables and are identified by a unique name. They group\nstateful information from rules, to reference them in rules the keywords \"type name\" are used\ne.g. \"counter name\".\n\n\nadd      Add a new stateful object in the\nspecified table.\n\ndelete   Delete the specified object.\n\nlist     Display stateful information the\nobject holds.\n\nreset    List-and-reset stateful object.\n\n\nCT HELPER\nadd ct helper [family] table name { type type protocol protocol ; [l3proto family ;] }\ndelete ct helper [family] table name\nlist ct helpers\n\nCt helper is used to define connection tracking helpers that can then be used in combination\nwith the ct helper set statement. type and protocol are mandatory, l3proto is derived from\nthe table family by default, i.e. in the inet table the kernel will try to load both the ipv4\nand ipv6 helper backends, if they are supported by the kernel.\n",
            "subsections": [
                {
                    "name": "Table 11. conntrack helper specifications",
                    "content": "┌─────────┬─────────────────────────┬──────────────────────────┐\n│Keyword  │ Description             │ Type                     │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│type     │ name of helper type     │ quoted string (e.g.      │\n│         │                         │ \"ftp\")                   │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│protocol │ layer 4 protocol of the │ string (e.g. ip)         │\n│         │ helper                  │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│l3proto  │ layer 3 protocol of the │ address family (e.g. ip) │\n│         │ helper                  │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│comment  │ per ct helper comment   │ string                   │\n│         │ field                   │                          │\n└─────────┴─────────────────────────┴──────────────────────────┘\n\ndefining and assigning ftp helper.\n\nUnlike iptables, helper assignment needs to be performed after the conntrack\nlookup has completed, for example with the default 0 hook priority.\n\ntable inet myhelpers {\nct helper ftp-standard {\ntype \"ftp\" protocol tcp\n}\nchain prerouting {\ntype filter hook prerouting priority filter;\ntcp dport 21 ct helper set \"ftp-standard\"\n}\n}\n\n\nCT TIMEOUT\nadd ct timeout  [family] table name { protocol protocol ; policy = { state: value [, ...] } ; [l3proto family ;] }\ndelete ct timeout [family] table name\nlist ct timeouts\n\nCt timeout is used to update connection tracking timeout values.Timeout policies are assigned\nwith the ct timeout set statement. protocol and policy are mandatory, l3proto is derived from\nthe table family by default.\n"
                },
                {
                    "name": "Table 12. conntrack timeout specifications",
                    "content": "┌─────────┬─────────────────────────┬──────────────────────────┐\n│Keyword  │ Description             │ Type                     │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│protocol │ layer 4 protocol of the │ string (e.g. ip)         │\n│         │ timeout object          │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│state    │ connection state name   │ string (e.g.             │\n│         │                         │ \"established\")           │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│value    │ timeout value for       │ unsigned integer         │\n│         │ connection state        │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│l3proto  │ layer 3 protocol of the │ address family (e.g. ip) │\n│         │ timeout object          │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│comment  │ per ct timeout comment  │ string                   │\n│         │ field                   │                          │\n└─────────┴─────────────────────────┴──────────────────────────┘\n\ntcp connection state names that can have a specific timeout value are:\n\nclose, closewait, established, finwait, lastack, retrans, synrecv, synsent, timewait\nand unack.\n\nYou can use sysctl -a |grep net.netfilter.nfconntracktcptimeout to view and change the\nsystem-wide defaults. ct timeout allows for flow-specific settings, without changing the\nglobal timeouts.\n\nFor example, tcp port 53 could have much lower settings than other traffic.\n\nudp state names that can have a specific timeout value are replied and unreplied.\n\ndefining and assigning ct timeout policy.\n\ntable ip filter {\nct timeout customtimeout {\nprotocol tcp;\nl3proto ip\npolicy = { established: 120, close: 20 }\n}\n\nchain output {\ntype filter hook output priority filter; policy accept;\nct timeout set \"customtimeout\"\n}\n}\n\ntesting the updated timeout policy.\n\n% conntrack -E\n\nIt should display:\n\n[UPDATE] tcp      6 120 ESTABLISHED src=172.16.19.128 dst=172.16.19.1\nsport=22 dport=41360 [UNREPLIED] src=172.16.19.1 dst=172.16.19.128\nsport=41360 dport=22\n\n\nCT EXPECTATION\nadd ct expectation  [family] table name { protocol protocol ; dport dport ; timeout timeout ; size size ; [*l3proto family ;] }\ndelete ct expectation  [family] table name\nlist ct expectations\n\nCt expectation is used to create connection expectations. Expectations are assigned with the\nct expectation set statement. protocol, dport, timeout and size are mandatory, l3proto is\nderived from the table family by default.\n"
                },
                {
                    "name": "Table 13. conntrack expectation specifications",
                    "content": "┌─────────┬─────────────────────────┬──────────────────────────┐\n│Keyword  │ Description             │ Type                     │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│protocol │ layer 4 protocol of the │ string (e.g. ip)         │\n│         │ expectation object      │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│dport    │ destination port of     │ unsigned integer         │\n│         │ expected connection     │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│timeout  │ timeout value for       │ unsigned integer         │\n│         │ expectation             │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│size     │ size value for          │ unsigned integer         │\n│         │ expectation             │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│l3proto  │ layer 3 protocol of the │ address family (e.g. ip) │\n│         │ expectation object      │                          │\n├─────────┼─────────────────────────┼──────────────────────────┤\n│         │                         │                          │\n│comment  │ per ct expectation      │ string                   │\n│         │ comment field           │                          │\n└─────────┴─────────────────────────┴──────────────────────────┘\n\ndefining and assigning ct expectation policy.\n\ntable ip filter {\nct expectation expect {\nprotocol udp\ndport 9876\ntimeout 2m\nsize 8\nl3proto ip\n}\n\nchain input {\ntype filter hook input priority filter; policy accept;\nct expectation set \"expect\"\n}\n}\n\n\nCOUNTER\nadd counter [family] table name [{ [ packets packets bytes bytes ; ] [ comment comment ; }]\ndelete counter [family] table name\nlist counters\n"
                },
                {
                    "name": "Table 14. Counter specifications",
                    "content": "┌────────┬───────────────────────────┬───────────────────────────┐\n│Keyword │ Description               │ Type                      │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│packets │ initial count of packets  │ unsigned integer (64 bit) │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│bytes   │ initial count of bytes    │ unsigned integer (64 bit) │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│comment │ per counter comment field │ string                    │\n└────────┴───────────────────────────┴───────────────────────────┘\n\nUsing named counters.\n\nnft add counter filter http\nnft add rule filter input tcp dport 80 counter name \\\"http\\\"\n\nUsing named counters with maps.\n\nnft add counter filter http\nnft add counter filter https\nnft add rule filter input counter name tcp dport map { 80 : \\\"http\\\", 443 : \\\"https\\\" }\n\n\nQUOTA\nadd quota [family] table name { [over|until] bytes BYTEUNIT [ used bytes BYTEUNIT ] ; [ comment comment ; ] }\nBYTEUNIT := bytes | kbytes | mbytes\ndelete quota [family] table name\nlist quotas\n"
                },
                {
                    "name": "Table 15. Quota specifications",
                    "content": "┌────────┬──────────────────────────┬─────────────────────────┐\n│Keyword │ Description              │ Type                    │\n├────────┼──────────────────────────┼─────────────────────────┤\n│        │                          │                         │\n│quota   │ quota limit, used as the │ Two arguments, unsigned │\n│        │ quota name               │ integer (64 bit) and    │\n│        │                          │ string: bytes, kbytes,  │\n│        │                          │ mbytes. \"over\" and      │\n│        │                          │ \"until\" go before these │\n│        │                          │ arguments               │\n├────────┼──────────────────────────┼─────────────────────────┤\n│        │                          │                         │\n│used    │ initial value of used    │ Two arguments, unsigned │\n│        │ quota                    │ integer (64 bit) and    │\n│        │                          │ string: bytes, kbytes,  │\n│        │                          │ mbytes                  │\n├────────┼──────────────────────────┼─────────────────────────┤\n│        │                          │                         │\n│comment │ per quota comment field  │ string                  │\n└────────┴──────────────────────────┴─────────────────────────┘\n\nUsing named quotas.\n\nnft add quota filter user123 { over 20 mbytes }\nnft add rule filter input ip saddr 192.168.10.123 quota name \\\"user123\\\"\n\nUsing named quotas with maps.\n\nnft add quota filter user123 { over 20 mbytes }\nnft add quota filter user124 { over 20 mbytes }\nnft add rule filter input quota name ip saddr map { 192.168.10.123 : \\\"user123\\\", 192.168.10.124 : \\\"user124\\\" }\n\n"
                }
            ]
        },
        "EXPRESSIONS": {
            "content": "Expressions represent values, either constants like network addresses, port numbers, etc., or\ndata gathered from the packet during ruleset evaluation. Expressions can be combined using\nbinary, logical, relational and other types of expressions to form complex or relational\n(match) expressions. They are also used as arguments to certain types of operations, like\nNAT, packet marking etc.\n\nEach expression has a data type, which determines the size, parsing and representation of\nsymbolic values and type compatibility with other expressions.\n\nDESCRIBE COMMAND\ndescribe expression | data type\n\nThe describe command shows information about the type of an expression and its data type. A\ndata type may also be given, in which nft will display more information about the type.\n\nThe describe command.\n\n$ nft describe tcp flags\npayload expression, datatype tcpflag (TCP flag) (basetype bitmask, integer), 8 bits\n\npredefined symbolic constants:\nfin                           0x01\nsyn                           0x02\nrst                           0x04\npsh                           0x08\nack                           0x10\nurg                           0x20\necn                           0x40\ncwr                           0x80\n\n",
            "subsections": []
        },
        "DATA TYPES": {
            "content": "Data types determine the size, parsing and representation of symbolic values and type\ncompatibility of expressions. A number of global data types exist, in addition some\nexpression types define further data types specific to the expression type. Most data types\nhave a fixed size, some however may have a dynamic size, f.i. the string type. Some types\nalso have predefined symbolic constants. Those can be listed using the nft describe command:\n\n$ nft describe ctstate\ndatatype ctstate (conntrack state) (basetype bitmask, integer), 32 bits\n\npre-defined symbolic constants (in hexadecimal):\ninvalid                         0x00000001\nnew ...\n\nTypes may be derived from lower order types, f.i. the IPv4 address type is derived from the\ninteger type, meaning an IPv4 address can also be specified as an integer value.\n\nIn certain contexts (set and map definitions), it is necessary to explicitly specify a data\ntype. Each type has a name which is used for this.\n\nINTEGER TYPE\n┌────────┬─────────┬──────────┬───────────┐\n│Name    │ Keyword │ Size     │ Base type │\n├────────┼─────────┼──────────┼───────────┤\n│        │         │          │           │\n│Integer │ integer │ variable │ -         │\n└────────┴─────────┴──────────┴───────────┘\n\nThe integer type is used for numeric values. It may be specified as a decimal, hexadecimal or\noctal number. The integer type does not have a fixed size, its size is determined by the\nexpression for which it is used.\n\nBITMASK TYPE\n┌────────┬─────────┬──────────┬───────────┐\n│Name    │ Keyword │ Size     │ Base type │\n├────────┼─────────┼──────────┼───────────┤\n│        │         │          │           │\n│Bitmask │ bitmask │ variable │ integer   │\n└────────┴─────────┴──────────┴───────────┘\n\nThe bitmask type (bitmask) is used for bitmasks.\n\nSTRING TYPE\n┌───────┬─────────┬──────────┬───────────┐\n│Name   │ Keyword │ Size     │ Base type │\n├───────┼─────────┼──────────┼───────────┤\n│       │         │          │           │\n│String │ string  │ variable │ -         │\n└───────┴─────────┴──────────┴───────────┘\n\nThe string type is used for character strings. A string begins with an alphabetic character\n(a-zA-Z) followed by zero or more alphanumeric characters or the characters /, -,  and .. In\naddition, anything enclosed in double quotes (\") is recognized as a string.\n\nString specification.\n\n# Interface name\nfilter input iifname eth0\n\n# Weird interface name\nfilter input iifname \"(eth0)\"\n\n\nLINK LAYER ADDRESS TYPE\n┌───────────────────┬─────────┬──────────┬───────────┐\n│Name               │ Keyword │ Size     │ Base type │\n├───────────────────┼─────────┼──────────┼───────────┤\n│                   │         │          │           │\n│Link layer address │ lladdr  │ variable │ integer   │\n└───────────────────┴─────────┴──────────┴───────────┘\n\nThe link layer address type is used for link layer addresses. Link layer addresses are\nspecified as a variable amount of groups of two hexadecimal digits separated using colons\n(:).\n\nLink layer address specification.\n\n# Ethernet destination MAC address\nfilter input ether daddr 20:c9:d0:43:12:d9\n\n\nIPV4 ADDRESS TYPE\n┌─────────────┬───────────┬────────┬───────────┐\n│Name         │ Keyword   │ Size   │ Base type │\n├─────────────┼───────────┼────────┼───────────┤\n│             │           │        │           │\n│IPV4 address │ ipv4addr │ 32 bit │ integer   │\n└─────────────┴───────────┴────────┴───────────┘\n\nThe IPv4 address type is used for IPv4 addresses. Addresses are specified in either dotted\ndecimal, dotted hexadecimal, dotted octal, decimal, hexadecimal, octal notation or as a host\nname. A host name will be resolved using the standard system resolver.\n\nIPv4 address specification.\n\n# dotted decimal notation\nfilter output ip daddr 127.0.0.1\n\n# host name\nfilter output ip daddr localhost\n\n\nIPV6 ADDRESS TYPE\n┌─────────────┬───────────┬─────────┬───────────┐\n│Name         │ Keyword   │ Size    │ Base type │\n├─────────────┼───────────┼─────────┼───────────┤\n│             │           │         │           │\n│IPv6 address │ ipv6addr │ 128 bit │ integer   │\n└─────────────┴───────────┴─────────┴───────────┘\n\nThe IPv6 address type is used for IPv6 addresses. Addresses are specified as a host name or\nas hexadecimal halfwords separated by colons. Addresses might be enclosed in square brackets\n(\"[]\") to differentiate them from port numbers.\n\nIPv6 address specification.\n\n# abbreviated loopback address\nfilter output ip6 daddr ::1\n\nIPv6 address specification with bracket notation.\n\n# without [] the port number (22) would be parsed as part of the\n# ipv6 address\nip6 nat prerouting tcp dport 2222 dnat to [1ce::d0]:22\n\n\nBOOLEAN TYPE\n┌────────┬─────────┬───────┬───────────┐\n│Name    │ Keyword │ Size  │ Base type │\n├────────┼─────────┼───────┼───────────┤\n│        │         │       │           │\n│Boolean │ boolean │ 1 bit │ integer   │\n└────────┴─────────┴───────┴───────────┘\n\nThe boolean type is a syntactical helper type in userspace. Its use is in the right-hand side\nof a (typically implicit) relational expression to change the expression on the left-hand\nside into a boolean check (usually for existence).\n",
            "subsections": [
                {
                    "name": "Table 16. The following keywords will automatically resolve into a boolean type with given",
                    "content": ""
                },
                {
                    "name": "value",
                    "content": "┌────────┬───────┐\n│Keyword │ Value │\n├────────┼───────┤\n│        │       │\n│exists  │ 1     │\n├────────┼───────┤\n│        │       │\n│missing │ 0     │\n└────────┴───────┘\n"
                },
                {
                    "name": "Table 17. expressions support a boolean comparison",
                    "content": "┌───────────┬─────────────────────────────┐\n│Expression │ Behaviour                   │\n├───────────┼─────────────────────────────┤\n│           │                             │\n│fib        │ Check route existence.      │\n├───────────┼─────────────────────────────┤\n│           │                             │\n│exthdr     │ Check IPv6 extension header │\n│           │ existence.                  │\n├───────────┼─────────────────────────────┤\n│           │                             │\n│tcp option │ Check TCP option header     │\n│           │ existence.                  │\n└───────────┴─────────────────────────────┘\n\nBoolean specification.\n\n# match if route exists\nfilter input fib daddr . iif oif exists\n\n# match only non-fragmented packets in IPv6 traffic\nfilter input exthdr frag missing\n\n# match if TCP timestamp option is present\nfilter input tcp option timestamp exists\n\n\nICMP TYPE TYPE\n┌──────────┬───────────┬───────┬───────────┐\n│Name      │ Keyword   │ Size  │ Base type │\n├──────────┼───────────┼───────┼───────────┤\n│          │           │       │           │\n│ICMP Type │ icmptype │ 8 bit │ integer   │\n└──────────┴───────────┴───────┴───────────┘\n\nThe ICMP Type type is used to conveniently specify the ICMP header’s type field.\n"
                },
                {
                    "name": "Table 18. Keywords may be used when specifying the ICMP type",
                    "content": "┌────────────────────────┬───────┐\n│Keyword                 │ Value │\n├────────────────────────┼───────┤\n│                        │       │\n│echo-reply              │ 0     │\n├────────────────────────┼───────┤\n│                        │       │\n│destination-unreachable │ 3     │\n├────────────────────────┼───────┤\n│                        │       │\n│source-quench           │ 4     │\n├────────────────────────┼───────┤\n│                        │       │\n│redirect                │ 5     │\n├────────────────────────┼───────┤\n│                        │       │\n│echo-request            │ 8     │\n├────────────────────────┼───────┤\n│                        │       │\n│router-advertisement    │ 9     │\n├────────────────────────┼───────┤\n│                        │       │\n│router-solicitation     │ 10    │\n├────────────────────────┼───────┤\n│                        │       │\n│time-exceeded           │ 11    │\n├────────────────────────┼───────┤\n│                        │       │\n│parameter-problem       │ 12    │\n├────────────────────────┼───────┤\n│                        │       │\n│timestamp-request       │ 13    │\n├────────────────────────┼───────┤\n│                        │       │\n│timestamp-reply         │ 14    │\n├────────────────────────┼───────┤\n│                        │       │\n│info-request            │ 15    │\n├────────────────────────┼───────┤\n│                        │       │\n│info-reply              │ 16    │\n├────────────────────────┼───────┤\n│                        │       │\n│address-mask-request    │ 17    │\n├────────────────────────┼───────┤\n│                        │       │\n│address-mask-reply      │ 18    │\n└────────────────────────┴───────┘\n\nICMP Type specification.\n\n# match ping packets\nfilter output icmp type { echo-request, echo-reply }\n\n\nICMP CODE TYPE\n┌──────────┬───────────┬───────┬───────────┐\n│Name      │ Keyword   │ Size  │ Base type │\n├──────────┼───────────┼───────┼───────────┤\n│          │           │       │           │\n│ICMP Code │ icmpcode │ 8 bit │ integer   │\n└──────────┴───────────┴───────┴───────────┘\n\nThe ICMP Code type is used to conveniently specify the ICMP header’s code field.\n"
                },
                {
                    "name": "Table 19. Keywords may be used when specifying the ICMP code",
                    "content": "┌─────────────────┬───────┐\n│Keyword          │ Value │\n├─────────────────┼───────┤\n│                 │       │\n│net-unreachable  │ 0     │\n├─────────────────┼───────┤\n│                 │       │\n│host-unreachable │ 1     │\n├─────────────────┼───────┤\n│                 │       │\n│prot-unreachable │ 2     │\n├─────────────────┼───────┤\n│                 │       │\n│port-unreachable │ 3     │\n├─────────────────┼───────┤\n│                 │       │\n│frag-needed      │ 4     │\n├─────────────────┼───────┤\n│                 │       │\n│net-prohibited   │ 9     │\n├─────────────────┼───────┤\n│                 │       │\n│host-prohibited  │ 10    │\n├─────────────────┼───────┤\n│                 │       │\n│admin-prohibited │ 13    │\n└─────────────────┴───────┘\n\nICMPV6 TYPE TYPE\n┌────────────┬────────────┬───────┬───────────┐\n│Name        │ Keyword    │ Size  │ Base type │\n├────────────┼────────────┼───────┼───────────┤\n│            │            │       │           │\n│ICMPv6 Type │ icmpxcode │ 8 bit │ integer   │\n└────────────┴────────────┴───────┴───────────┘\n\nThe ICMPv6 Type type is used to conveniently specify the ICMPv6 header’s type field.\n"
                },
                {
                    "name": "Table 20. keywords may be used when specifying the ICMPv6 type:",
                    "content": "┌────────────────────────┬───────┐\n│Keyword                 │ Value │\n├────────────────────────┼───────┤\n│                        │       │\n│destination-unreachable │ 1     │\n├────────────────────────┼───────┤\n│                        │       │\n│packet-too-big          │ 2     │\n├────────────────────────┼───────┤\n│                        │       │\n│time-exceeded           │ 3     │\n├────────────────────────┼───────┤\n│                        │       │\n│parameter-problem       │ 4     │\n├────────────────────────┼───────┤\n│                        │       │\n│echo-request            │ 128   │\n├────────────────────────┼───────┤\n│                        │       │\n│echo-reply              │ 129   │\n├────────────────────────┼───────┤\n│                        │       │\n│mld-listener-query      │ 130   │\n├────────────────────────┼───────┤\n│                        │       │\n│mld-listener-report     │ 131   │\n├────────────────────────┼───────┤\n│                        │       │\n│mld-listener-done       │ 132   │\n├────────────────────────┼───────┤\n│                        │       │\n│mld-listener-reduction  │ 132   │\n├────────────────────────┼───────┤\n│                        │       │\n│nd-router-solicit       │ 133   │\n├────────────────────────┼───────┤\n│                        │       │\n│nd-router-advert        │ 134   │\n├────────────────────────┼───────┤\n│                        │       │\n│nd-neighbor-solicit     │ 135   │\n├────────────────────────┼───────┤\n│                        │       │\n│nd-neighbor-advert      │ 136   │\n├────────────────────────┼───────┤\n│                        │       │\n│nd-redirect             │ 137   │\n├────────────────────────┼───────┤\n│                        │       │\n│router-renumbering      │ 138   │\n├────────────────────────┼───────┤\n│                        │       │\n│ind-neighbor-solicit    │ 141   │\n├────────────────────────┼───────┤\n│                        │       │\n│ind-neighbor-advert     │ 142   │\n├────────────────────────┼───────┤\n│                        │       │\n│mld2-listener-report    │ 143   │\n└────────────────────────┴───────┘\n\nICMPv6 Type specification.\n\n# match ICMPv6 ping packets\nfilter output icmpv6 type { echo-request, echo-reply }\n\n\nICMPV6 CODE TYPE\n┌────────────┬─────────────┬───────┬───────────┐\n│Name        │ Keyword     │ Size  │ Base type │\n├────────────┼─────────────┼───────┼───────────┤\n│            │             │       │           │\n│ICMPv6 Code │ icmpv6code │ 8 bit │ integer   │\n└────────────┴─────────────┴───────┴───────────┘\n\nThe ICMPv6 Code type is used to conveniently specify the ICMPv6 header’s code field.\n"
                },
                {
                    "name": "Table 21. keywords may be used when specifying the ICMPv6 code",
                    "content": "┌─────────────────┬───────┐\n│Keyword          │ Value │\n├─────────────────┼───────┤\n│                 │       │\n│no-route         │ 0     │\n├─────────────────┼───────┤\n│                 │       │\n│admin-prohibited │ 1     │\n├─────────────────┼───────┤\n│                 │       │\n│addr-unreachable │ 3     │\n├─────────────────┼───────┤\n│                 │       │\n│port-unreachable │ 4     │\n├─────────────────┼───────┤\n│                 │       │\n│policy-fail      │ 5     │\n├─────────────────┼───────┤\n│                 │       │\n│reject-route     │ 6     │\n└─────────────────┴───────┘\n\nICMPVX CODE TYPE\n┌────────────┬─────────────┬───────┬───────────┐\n│Name        │ Keyword     │ Size  │ Base type │\n├────────────┼─────────────┼───────┼───────────┤\n│            │             │       │           │\n│ICMPvX Code │ icmpv6type │ 8 bit │ integer   │\n└────────────┴─────────────┴───────┴───────────┘\n\nThe ICMPvX Code type abstraction is a set of values which overlap between ICMP and ICMPv6\nCode types to be used from the inet family.\n"
                },
                {
                    "name": "Table 22. keywords may be used when specifying the ICMPvX code",
                    "content": "┌─────────────────┬───────┐\n│Keyword          │ Value │\n├─────────────────┼───────┤\n│                 │       │\n│no-route         │ 0     │\n├─────────────────┼───────┤\n│                 │       │\n│port-unreachable │ 1     │\n├─────────────────┼───────┤\n│                 │       │\n│host-unreachable │ 2     │\n├─────────────────┼───────┤\n│                 │       │\n│admin-prohibited │ 3     │\n└─────────────────┴───────┘\n\nCONNTRACK TYPES"
                },
                {
                    "name": "Table 23. overview of types used in ct expression and statement",
                    "content": "┌─────────────────────┬───────────┬─────────┬───────────┐\n│Name                 │ Keyword   │ Size    │ Base type │\n├─────────────────────┼───────────┼─────────┼───────────┤\n│                     │           │         │           │\n│conntrack state      │ ctstate  │ 4 byte  │ bitmask   │\n├─────────────────────┼───────────┼─────────┼───────────┤\n│                     │           │         │           │\n│conntrack direction  │ ctdir    │ 8 bit   │ integer   │\n├─────────────────────┼───────────┼─────────┼───────────┤\n│                     │           │         │           │\n│conntrack status     │ ctstatus │ 4 byte  │ bitmask   │\n├─────────────────────┼───────────┼─────────┼───────────┤\n│                     │           │         │           │\n│conntrack event bits │ ctevent  │ 4 byte  │ bitmask   │\n├─────────────────────┼───────────┼─────────┼───────────┤\n│                     │           │         │           │\n│conntrack label      │ ctlabel  │ 128 bit │ bitmask   │\n└─────────────────────┴───────────┴─────────┴───────────┘\n\nFor each of the types above, keywords are available for convenience:\n\nTable 24. conntrack state (ctstate)\n┌────────────┬───────┐\n│Keyword     │ Value │\n├────────────┼───────┤\n│            │       │\n│invalid     │ 1     │\n├────────────┼───────┤\n│            │       │\n│established │ 2     │\n├────────────┼───────┤\n│            │       │\n│related     │ 4     │\n├────────────┼───────┤\n│            │       │\n│new         │ 8     │\n├────────────┼───────┤\n│            │       │\n│untracked   │ 64    │\n└────────────┴───────┘\n\nTable 25. conntrack direction (ctdir)\n┌─────────┬───────┐\n│Keyword  │ Value │\n├─────────┼───────┤\n│         │       │\n│original │ 0     │\n├─────────┼───────┤\n│         │       │\n│reply    │ 1     │\n└─────────┴───────┘\n\nTable 26. conntrack status (ctstatus)\n┌───────────┬───────┐\n│Keyword    │ Value │\n├───────────┼───────┤\n│           │       │\n│expected   │ 1     │\n├───────────┼───────┤\n│           │       │\n│seen-reply │ 2     │\n├───────────┼───────┤\n│           │       │\n│assured    │ 4     │\n├───────────┼───────┤\n│           │       │\n│confirmed  │ 8     │\n├───────────┼───────┤\n│           │       │\n│snat       │ 16    │\n├───────────┼───────┤\n│           │       │\n│dnat       │ 32    │\n├───────────┼───────┤\n│           │       │\n│dying      │ 512   │\n└───────────┴───────┘\n\nTable 27. conntrack event bits (ctevent)\n┌──────────┬───────┐\n│Keyword   │ Value │\n├──────────┼───────┤\n│          │       │\n│new       │ 1     │\n├──────────┼───────┤\n│          │       │\n│related   │ 2     │\n├──────────┼───────┤\n│          │       │\n│destroy   │ 4     │\n├──────────┼───────┤\n│          │       │\n│reply     │ 8     │\n├──────────┼───────┤\n│          │       │\n│assured   │ 16    │\n├──────────┼───────┤\n│          │       │\n│protoinfo │ 32    │\n├──────────┼───────┤\n│          │       │\n│helper    │ 64    │\n├──────────┼───────┤\n│          │       │\n│mark      │ 128   │\n├──────────┼───────┤\n│          │       │\n│seqadj    │ 256   │\n├──────────┼───────┤\n│          │       │\n│secmark   │ 512   │\n├──────────┼───────┤\n│          │       │\n│label     │ 1024  │\n└──────────┴───────┘\n\nPossible keywords for conntrack label type (ctlabel) are read at runtime from\n/etc/connlabel.conf.\n\nDCCP PKTTYPE TYPE\n┌─────────────────┬──────────────┬───────┬───────────┐\n│Name             │ Keyword      │ Size  │ Base type │\n├─────────────────┼──────────────┼───────┼───────────┤\n│                 │              │       │           │\n│DCCP packet type │ dccppkttype │ 4 bit │ integer   │\n└─────────────────┴──────────────┴───────┴───────────┘\n\nThe DCCP packet type abstracts the different legal values of the respective four bit field in\nthe DCCP header, as stated by RFC4340. Note that possible values 10-15 are considered\nreserved and therefore not allowed to be used. In iptables' dccp match, these values are\naliased INVALID. With nftables, one may simply match on the numeric value range, i.e. 10-15.\n"
                },
                {
                    "name": "Table 28. keywords may be used when specifying the DCCP packet type",
                    "content": "┌─────────┬───────┐\n│Keyword  │ Value │\n├─────────┼───────┤\n│         │       │\n│request  │ 0     │\n├─────────┼───────┤\n│         │       │\n│response │ 1     │\n├─────────┼───────┤\n│         │       │\n│data     │ 2     │\n├─────────┼───────┤\n│         │       │\n│ack      │ 3     │\n├─────────┼───────┤\n│         │       │\n│dataack  │ 4     │\n├─────────┼───────┤\n│         │       │\n│closereq │ 5     │\n├─────────┼───────┤\n│         │       │\n│close    │ 6     │\n├─────────┼───────┤\n│         │       │\n│reset    │ 7     │\n├─────────┼───────┤\n│         │       │\n│sync     │ 8     │\n├─────────┼───────┤\n│         │       │\n│syncack  │ 9     │\n└─────────┴───────┘\n"
                }
            ]
        },
        "PRIMARY EXPRESSIONS": {
            "content": "The lowest order expression is a primary expression, representing either a constant or a\nsingle datum from a packet’s payload, meta data or a stateful module.\n\nMETA EXPRESSIONS\nmeta {length | nfproto | l4proto | protocol | priority}\n[meta] {mark | iif | iifname | iiftype | oif | oifname | oiftype | skuid | skgid | nftrace | rtclassid | ibrname | obrname | pkttype | cpu | iifgroup | oifgroup | cgroup | random | ipsec | iifkind | oifkind | time | hour | day }\n\nA meta expression refers to meta data associated with a packet.\n\nThere are two types of meta expressions: unqualified and qualified meta expressions.\nQualified meta expressions require the meta keyword before the meta key, unqualified meta\nexpressions can be specified by using the meta key directly or as qualified meta expressions.\nMeta l4proto is useful to match a particular transport protocol that is part of either an\nIPv4 or IPv6 packet. It will also skip any IPv6 extension headers present in an IPv6 packet.\n\nmeta iif, oif, iifname and oifname are used to match the interface a packet arrived on or is\nabout to be sent out on.\n\niif and oif are used to match on the interface index, whereas iifname and oifname are used to\nmatch on the interface name. This is not the same — assuming the rule\n\nfilter input meta iif \"foo\"\n\nThen this rule can only be added if the interface \"foo\" exists. Also, the rule will continue\nto match even if the interface \"foo\" is renamed to \"bar\".\n\nThis is because internally the interface index is used. In case of dynamically created\ninterfaces, such as tun/tap or dialup interfaces (ppp for example), it might be better to use\niifname or oifname instead.\n\nIn these cases, the name is used so the interface doesn’t have to exist to add such a rule,\nit will stop matching if the interface gets renamed and it will match again in case interface\ngets deleted and later a new interface with the same name is created.\n\nLike with iptables, wildcard matching on interface name prefixes is available for iifname and\noifname matches by appending an asterisk (*) character. Note however that unlike iptables,\nnftables does not accept interface names consisting of the wildcard character only - users\nare supposed to just skip those always matching expressions. In order to match on literal\nasterisk character, one may escape it using backslash (\\).\n",
            "subsections": [
                {
                    "name": "Table 29. Meta expression types",
                    "content": "┌──────────┬───────────────────────────┬───────────────────────────┐\n│Keyword   │ Description               │ Type                      │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│length    │ Length of the packet in   │ integer (32-bit)          │\n│          │ bytes                     │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│nfproto   │ real hook protocol        │ integer (32 bit)          │\n│          │ family, useful only in    │                           │\n│          │ inet table                │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│l4proto   │ layer 4 protocol, skips   │ integer (8 bit)           │\n│          │ ipv6 extension headers    │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│protocol  │ EtherType protocol value  │ ethertype                │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│priority  │ TC packet priority        │ tchandle                 │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│mark      │ Packet mark               │ mark                      │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│iif       │ Input interface index     │ ifaceindex               │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│iifname   │ Input interface name      │ ifname                    │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│iiftype   │ Input interface type      │ ifacetype                │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│oif       │ Output interface index    │ ifaceindex               │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│oifname   │ Output interface name     │ ifname                    │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│oiftype   │ Output interface hardware │ ifacetype                │\n│          │ type                      │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│sdif      │ Slave device input        │ ifaceindex               │\n│          │ interface index           │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│sdifname  │ Slave device interface    │ ifname                    │\n│          │ name                      │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│skuid     │ UID associated with       │ uid                       │\n│          │ originating socket        │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│skgid     │ GID associated with       │ gid                       │\n│          │ originating socket        │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│rtclassid │ Routing realm             │ realm                     │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│ibrname   │ Input bridge interface    │ ifname                    │\n│          │ name                      │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│obrname   │ Output bridge interface   │ ifname                    │\n│          │ name                      │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│pkttype   │ packet type               │ pkttype                  │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│cpu       │ cpu number processing the │ integer (32 bit)          │\n│          │ packet                    │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│iifgroup  │ incoming device group     │ devgroup                  │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│oifgroup  │ outgoing device group     │ devgroup                  │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│cgroup    │ control group id          │ integer (32 bit)          │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│random    │ pseudo-random number      │ integer (32 bit)          │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│ipsec     │ true if packet was ipsec  │ boolean (1 bit)           │\n│          │ encrypted                 │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│iifkind   │ Input interface kind      │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│oifkind   │ Output interface kind     │                           │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│time      │ Absolute time of packet   │ Integer (32 bit) or       │\n│          │ reception                 │ string                    │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│day       │ Day of week               │ Integer (8 bit) or string │\n├──────────┼───────────────────────────┼───────────────────────────┤\n│          │                           │                           │\n│hour      │ Hour of day               │ String                    │\n└──────────┴───────────────────────────┴───────────────────────────┘\n"
                },
                {
                    "name": "Table 30. Meta expression specific types",
                    "content": "┌──────────────┬───────────────────────────────────┐\n│Type          │ Description                       │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│ifaceindex   │ Interface index (32 bit number).  │\n│              │ Can be specified numerically or   │\n│              │ as name of an existing interface. │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│ifname        │ Interface name (16 byte string).  │\n│              │ Does not have to exist.           │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│ifacetype    │ Interface type (16 bit number).   │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│uid           │ User ID (32 bit number). Can be   │\n│              │ specified numerically or as user  │\n│              │ name.                             │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│gid           │ Group ID (32 bit number). Can be  │\n│              │ specified numerically or as group │\n│              │ name.                             │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│realm         │ Routing Realm (32 bit number).    │\n│              │ Can be specified numerically or   │\n│              │ as symbolic name defined in       │\n│              │ /etc/iproute2/rtrealms.          │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│devgrouptype │ Device group (32 bit number). Can │\n│              │ be specified numerically or as    │\n│              │ symbolic name defined in          │\n│              │ /etc/iproute2/group.              │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│pkttype      │ Packet type: host (addressed to   │\n│              │ local host), broadcast (to all),  │\n│              │ multicast (to group), other       │\n│              │ (addressed to another host).      │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│ifkind        │ Interface kind (16 byte string).  │\n│              │ See TYPES in ip-link(8) for a     │\n│              │ list.                             │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│time          │ Either an integer or a date in    │\n│              │ ISO format. For example:          │\n│              │ \"2019-06-06 17:00\". Hour and      │\n│              │ seconds are optional and can be   │\n│              │ omitted if desired. If omitted,   │\n│              │ midnight will be assumed. The     │\n│              │ following three would be          │\n│              │ equivalent: \"2019-06-06\",         │\n│              │ \"2019-06-06 00:00\" and            │\n│              │ \"2019-06-06 00:00:00\". When an    │\n│              │ integer is given, it is assumed   │\n│              │ to be a UNIX timestamp.           │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│day           │ Either a day of week (\"Monday\",   │\n│              │ \"Tuesday\", etc.), or an integer   │\n│              │ between 0 and 6. Strings are      │\n│              │ matched case-insensitively, and a │\n│              │ full match is not expected (e.g.  │\n│              │ \"Mon\" would match \"Monday\"). When │\n│              │ an integer is given, 0 is Sunday  │\n│              │ and 6 is Saturday.                │\n├──────────────┼───────────────────────────────────┤\n│              │                                   │\n│hour          │ A string representing an hour in  │\n│              │ 24-hour format. Seconds can       │\n│              │ optionally be specified. For      │\n│              │ example, 17:00 and 17:00:00 would │\n│              │ be equivalent.                    │\n└──────────────┴───────────────────────────────────┘\n\nUsing meta expressions.\n\n# qualified meta expression\nfilter output meta oif eth0\nfilter forward meta iifkind { \"tun\", \"veth\" }\n\n# unqualified meta expression\nfilter output oif eth0\n\n# incoming packet was subject to ipsec processing\nraw prerouting meta ipsec exists accept\n\n\nSOCKET EXPRESSION\nsocket {transparent | mark | wildcard}\nsocket cgroupv2 level NUM\n\nSocket expression can be used to search for an existing open TCP/UDP socket and its\nattributes that can be associated with a packet. It looks for an established or non-zero\nbound listening socket (possibly with a non-local address). You can also use it to match on\nthe socket cgroupv2 at a given ancestor level, e.g. if the socket belongs to cgroupv2 a/b,\nancestor level 1 checks for a matching on cgroup a and ancestor level 2 checks for a matching\non cgroup b.\n"
                },
                {
                    "name": "Table 31. Available socket attributes",
                    "content": "┌────────────┬───────────────────────────┬─────────────────┐\n│Name        │ Description               │ Type            │\n├────────────┼───────────────────────────┼─────────────────┤\n│            │                           │                 │\n│transparent │ Value of the              │ boolean (1 bit) │\n│            │ IPTRANSPARENT socket     │                 │\n│            │ option in the found       │                 │\n│            │ socket. It can be 0 or 1. │                 │\n├────────────┼───────────────────────────┼─────────────────┤\n│            │                           │                 │\n│mark        │ Value of the socket mark  │ mark            │\n│            │ (SOLSOCKET, SOMARK).    │                 │\n├────────────┼───────────────────────────┼─────────────────┤\n│            │                           │                 │\n│wildcard    │ Indicates whether the     │ boolean (1 bit) │\n│            │ socket is wildcard-bound  │                 │\n│            │ (e.g. 0.0.0.0 or ::0).    │                 │\n├────────────┼───────────────────────────┼─────────────────┤\n│            │                           │                 │\n│cgroupv2    │ cgroup version 2 for this │ cgroupv2        │\n│            │ socket (path from         │                 │\n│            │ /sys/fs/cgroup)           │                 │\n└────────────┴───────────────────────────┴─────────────────┘\n\nUsing socket expression.\n\n# Mark packets that correspond to a transparent socket. \"socket wildcard 0\"\n# means that zero-bound listener sockets are NOT matched (which is usually\n# exactly what you want).\ntable inet x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\nsocket transparent 1 socket wildcard 0 mark set 0x00000001 accept\n}\n}\n\n# Trace packets that corresponds to a socket with a mark value of 15\ntable inet x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\nsocket mark 0x0000000f nftrace set 1\n}\n}\n\n# Set packet mark to socket mark\ntable inet x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\ntcp dport 8080 mark set socket mark\n}\n}\n\n# Count packets for cgroupv2 \"user.slice\" at level 1\ntable inet x {\nchain y {\ntype filter hook input priority filter; policy accept;\nsocket cgroupv2 level 1 \"user.slice\" counter\n}\n}\n\n\nOSF EXPRESSION\nosf [ttl {loose | skip}] {name | version}\n\nThe osf expression does passive operating system fingerprinting. This expression compares\nsome data (Window Size, MSS, options and their order, DF, and others) from packets with the\nSYN bit set.\n"
                },
                {
                    "name": "Table 32. Available osf attributes",
                    "content": "┌────────┬──────────────────────────┬────────┐\n│Name    │ Description              │ Type   │\n├────────┼──────────────────────────┼────────┤\n│        │                          │        │\n│ttl     │ Do TTL checks on the     │ string │\n│        │ packet to determine the  │        │\n│        │ operating system.        │        │\n├────────┼──────────────────────────┼────────┤\n│        │                          │        │\n│version │ Do OS version checks on  │        │\n│        │ the packet.              │        │\n├────────┼──────────────────────────┼────────┤\n│        │                          │        │\n│name    │ Name of the OS signature │ string │\n│        │ to match. All signatures │        │\n│        │ can be found at pf.os    │        │\n│        │ file. Use \"unknown\" for  │        │\n│        │ OS signatures that the   │        │\n│        │ expression could not     │        │\n│        │ detect.                  │        │\n└────────┴──────────────────────────┴────────┘\n\nAvailable ttl values.\n\nIf no TTL attribute is passed, make a true IP header and fingerprint TTL true comparison. This generally works for LANs.\n\n* loose: Check if the IP header's TTL is less than the fingerprint one. Works for globally-routable addresses.\n* skip: Do not compare the TTL at all.\n\nUsing osf expression.\n\n# Accept packets that match the \"Linux\" OS genre signature without comparing TTL.\ntable inet x {\nchain y {\ntype filter hook input priority filter; policy accept;\nosf ttl skip name \"Linux\"\n}\n}\n\n\nFIB EXPRESSIONS\nfib {saddr | daddr | mark | iif | oif} [. ...] {oif | oifname | type}\n\nA fib expression queries the fib (forwarding information base) to obtain information such as\nthe output interface index a particular address would use. The input is a tuple of elements\nthat is used as input to the fib lookup functions.\n"
                },
                {
                    "name": "Table 33. fib expression specific types",
                    "content": "┌────────┬────────────────────────┬──────────────────┐\n│Keyword │ Description            │ Type             │\n├────────┼────────────────────────┼──────────────────┤\n│        │                        │                  │\n│oif     │ Output interface index │ integer (32 bit) │\n├────────┼────────────────────────┼──────────────────┤\n│        │                        │                  │\n│oifname │ Output interface name  │ string           │\n├────────┼────────────────────────┼──────────────────┤\n│        │                        │                  │\n│type    │ Address type           │ fibaddrtype     │\n└────────┴────────────────────────┴──────────────────┘\n\nUse nft describe fibaddrtype to get a list of all address types.\n\nUsing fib expressions.\n\n# drop packets without a reverse path\nfilter prerouting fib saddr . iif oif missing drop\n\nIn this example, 'saddr . iif' looks up routing information based on the source address and the input interface.\noif picks the output interface index from the routing information.\nIf no route was found for the source address/input interface combination, the output interface index is zero.\nIn case the input interface is specified as part of the input key, the output interface index is always the same as the input interface index or zero.\nIf only 'saddr oif' is given, then oif can be any interface index or zero.\n\n# drop packets to address not configured on incoming interface\nfilter prerouting fib daddr . iif type != { local, broadcast, multicast } drop\n\n# perform lookup in a specific 'blackhole' table (0xdead, needs ip appropriate ip rule)\nfilter prerouting meta mark set 0xdead fib daddr . mark type vmap { blackhole : drop, prohibit : jump prohibited, unreachable : drop }\n\n\nROUTING EXPRESSIONS\nrt [ip | ip6] {classid | nexthop | mtu | ipsec}\n\nA routing expression refers to routing data associated with a packet.\n"
                },
                {
                    "name": "Table 34. Routing expression types",
                    "content": "┌────────┬───────────────────────────┬─────────────────────┐\n│Keyword │ Description               │ Type                │\n├────────┼───────────────────────────┼─────────────────────┤\n│        │                           │                     │\n│classid │ Routing realm             │ realm               │\n├────────┼───────────────────────────┼─────────────────────┤\n│        │                           │                     │\n│nexthop │ Routing nexthop           │ ipv4addr/ipv6addr │\n├────────┼───────────────────────────┼─────────────────────┤\n│        │                           │                     │\n│mtu     │ TCP maximum segment size  │ integer (16 bit)    │\n│        │ of route                  │                     │\n├────────┼───────────────────────────┼─────────────────────┤\n│        │                           │                     │\n│ipsec   │ route via ipsec tunnel or │ boolean             │\n│        │ transport                 │                     │\n└────────┴───────────────────────────┴─────────────────────┘\n"
                },
                {
                    "name": "Table 35. Routing expression specific types",
                    "content": "┌──────┬─────────────────────────────────┐\n│Type  │ Description                     │\n├──────┼─────────────────────────────────┤\n│      │                                 │\n│realm │ Routing Realm (32 bit number).  │\n│      │ Can be specified numerically or │\n│      │ as symbolic name defined in     │\n│      │ /etc/iproute2/rtrealms.        │\n└──────┴─────────────────────────────────┘\n\nUsing routing expressions.\n\n# IP family independent rt expression\nfilter output rt classid 10\n\n# IP family dependent rt expressions\nip filter output rt nexthop 192.168.0.1\nip6 filter output rt nexthop fd00::1\ninet filter output rt ip nexthop 192.168.0.1\ninet filter output rt ip6 nexthop fd00::1\n\n# outgoing packet will be encapsulated/encrypted by ipsec\nfilter output rt ipsec exists\n\n\nIPSEC EXPRESSIONS\nipsec {in | out} [ spnum NUM ]  {reqid | spi}\nipsec {in | out} [ spnum NUM ]  {ip | ip6} {saddr | daddr}\n\nAn ipsec expression refers to ipsec data associated with a packet.\n\nThe in or out keyword needs to be used to specify if the expression should examine inbound or\noutbound policies. The in keyword can be used in the prerouting, input and forward hooks. The\nout keyword applies to forward, output and postrouting hooks. The optional keyword spnum can\nbe used to match a specific state in a chain, it defaults to 0.\n"
                },
                {
                    "name": "Table 36. Ipsec expression types",
                    "content": "┌────────┬──────────────────────────┬─────────────────────┐\n│Keyword │ Description              │ Type                │\n├────────┼──────────────────────────┼─────────────────────┤\n│        │                          │                     │\n│reqid   │ Request ID               │ integer (32 bit)    │\n├────────┼──────────────────────────┼─────────────────────┤\n│        │                          │                     │\n│spi     │ Security Parameter Index │ integer (32 bit)    │\n├────────┼──────────────────────────┼─────────────────────┤\n│        │                          │                     │\n│saddr   │ Source address of the    │ ipv4addr/ipv6addr │\n│        │ tunnel                   │                     │\n├────────┼──────────────────────────┼─────────────────────┤\n│        │                          │                     │\n│daddr   │ Destination address of   │ ipv4addr/ipv6addr │\n│        │ the tunnel               │                     │\n└────────┴──────────────────────────┴─────────────────────┘\n\nNUMGEN EXPRESSION\nnumgen {inc | random} mod NUM [ offset NUM ]\n\nCreate a number generator. The inc or random keywords control its operation mode: In inc\nmode, the last returned value is simply incremented. In random mode, a new random number is\nreturned. The value after mod keyword specifies an upper boundary (read: modulus) which is\nnot reached by returned numbers. The optional offset allows to increment the returned value\nby a fixed offset.\n\nA typical use-case for numgen is load-balancing:\n\nUsing numgen expression.\n\n# round-robin between 192.168.10.100 and 192.168.20.200:\nadd rule nat prerouting dnat to numgen inc mod 2 map \\\n{ 0 : 192.168.10.100, 1 : 192.168.20.200 }\n\n# probability-based with odd bias using intervals:\nadd rule nat prerouting dnat to numgen random mod 10 map \\\n{ 0-2 : 192.168.10.100, 3-9 : 192.168.20.200 }\n\n\nHASH EXPRESSIONS\njhash {ip saddr | ip6 daddr | tcp dport | udp sport | ether saddr} [. ...] mod NUM [ seed NUM ] [ offset NUM ]\nsymhash mod NUM [ offset NUM ]\n\nUse a hashing function to generate a number. The functions available are jhash, known as\nJenkins Hash, and symhash, for Symmetric Hash. The jhash requires an expression to determine\nthe parameters of the packet header to apply the hashing, concatenations are possible as\nwell. The value after mod keyword specifies an upper boundary (read: modulus) which is not\nreached by returned numbers. The optional seed is used to specify an init value used as seed\nin the hashing function. The optional offset allows to increment the returned value by a\nfixed offset.\n\nA typical use-case for jhash and symhash is load-balancing:\n\nUsing hash expressions.\n\n# load balance based on source ip between 2 ip addresses:\nadd rule nat prerouting dnat to jhash ip saddr mod 2 map \\\n{ 0 : 192.168.10.100, 1 : 192.168.20.200 }\n\n# symmetric load balancing between 2 ip addresses:\nadd rule nat prerouting dnat to symhash mod 2 map \\\n{ 0 : 192.168.10.100, 1 : 192.168.20.200 }\n\n"
                }
            ]
        },
        "PAYLOAD EXPRESSIONS": {
            "content": "Payload expressions refer to data from the packet’s payload.\n\nETHERNET HEADER EXPRESSION\nether {daddr | saddr | type}\n",
            "subsections": [
                {
                    "name": "Table 37. Ethernet header expression types",
                    "content": "┌────────┬─────────────────────────┬────────────┐\n│Keyword │ Description             │ Type       │\n├────────┼─────────────────────────┼────────────┤\n│        │                         │            │\n│daddr   │ Destination MAC address │ etheraddr │\n├────────┼─────────────────────────┼────────────┤\n│        │                         │            │\n│saddr   │ Source MAC address      │ etheraddr │\n├────────┼─────────────────────────┼────────────┤\n│        │                         │            │\n│type    │ EtherType               │ ethertype │\n└────────┴─────────────────────────┴────────────┘\n\nVLAN HEADER EXPRESSION\nvlan {id | dei | pcp | type}\n"
                },
                {
                    "name": "Table 38. VLAN header expression",
                    "content": "┌────────┬─────────────────────────┬──────────────────┐\n│Keyword │ Description             │ Type             │\n├────────┼─────────────────────────┼──────────────────┤\n│        │                         │                  │\n│id      │ VLAN ID (VID)           │ integer (12 bit) │\n├────────┼─────────────────────────┼──────────────────┤\n│        │                         │                  │\n│dei     │ Drop Eligible Indicator │ integer (1 bit)  │\n├────────┼─────────────────────────┼──────────────────┤\n│        │                         │                  │\n│pcp     │ Priority code point     │ integer (3 bit)  │\n├────────┼─────────────────────────┼──────────────────┤\n│        │                         │                  │\n│type    │ EtherType               │ ethertype       │\n└────────┴─────────────────────────┴──────────────────┘\n\nARP HEADER EXPRESSION\narp {htype | ptype | hlen | plen | operation | saddr { ip | ether } | daddr { ip | ether }\n"
                },
                {
                    "name": "Table 39. ARP header expression",
                    "content": "┌────────────┬─────────────────────────┬──────────────────┐\n│Keyword     │ Description             │ Type             │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│htype       │ ARP hardware type       │ integer (16 bit) │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│ptype       │ EtherType               │ ethertype       │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│hlen        │ Hardware address len    │ integer (8 bit)  │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│plen        │ Protocol address len    │ integer (8 bit)  │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│operation   │ Operation               │ arpop           │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│saddr ether │ Ethernet sender address │ etheraddr       │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│daddr ether │ Ethernet target address │ etheraddr       │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│saddr ip    │ IPv4 sender address     │ ipv4addr        │\n├────────────┼─────────────────────────┼──────────────────┤\n│            │                         │                  │\n│daddr ip    │ IPv4 target address     │ ipv4addr        │\n└────────────┴─────────────────────────┴──────────────────┘\n\nIPV4 HEADER EXPRESSION\nip {version | hdrlength | dscp | ecn | length | id | frag-off | ttl | protocol | checksum | saddr | daddr }\n"
                },
                {
                    "name": "Table 40. IPv4 header expression",
                    "content": "┌──────────┬─────────────────────────┬───────────────────────┐\n│Keyword   │ Description             │ Type                  │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│version   │ IP header version (4)   │ integer (4 bit)       │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│hdrlength │ IP header length        │ integer (4 bit) FIXME │\n│          │ including options       │ scaling               │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│dscp      │ Differentiated Services │ dscp                  │\n│          │ Code Point              │                       │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│ecn       │ Explicit Congestion     │ ecn                   │\n│          │ Notification            │                       │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│length    │ Total packet length     │ integer (16 bit)      │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│id        │ IP ID                   │ integer (16 bit)      │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│frag-off  │ Fragment offset         │ integer (16 bit)      │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│ttl       │ Time to live            │ integer (8 bit)       │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│protocol  │ Upper layer protocol    │ inetproto            │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│checksum  │ IP header checksum      │ integer (16 bit)      │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│saddr     │ Source address          │ ipv4addr             │\n├──────────┼─────────────────────────┼───────────────────────┤\n│          │                         │                       │\n│daddr     │ Destination address     │ ipv4addr             │\n└──────────┴─────────────────────────┴───────────────────────┘\n\nICMP HEADER EXPRESSION\nicmp {type | code | checksum | id | sequence | gateway | mtu}\n\nThis expression refers to ICMP header fields. When using it in inet, bridge or netdev\nfamilies, it will cause an implicit dependency on IPv4 to be created. To match on unusual\ncases like ICMP over IPv6, one has to add an explicit meta protocol ip6 match to the rule.\n"
                },
                {
                    "name": "Table 41. ICMP header expression",
                    "content": "┌─────────┬───────────────────────────┬──────────────────┐\n│Keyword  │ Description               │ Type             │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│type     │ ICMP type field           │ icmptype        │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│code     │ ICMP code field           │ integer (8 bit)  │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│checksum │ ICMP checksum field       │ integer (16 bit) │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│id       │ ID of echo                │ integer (16 bit) │\n│         │ request/response          │                  │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│sequence │ sequence number of echo   │ integer (16 bit) │\n│         │ request/response          │                  │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│gateway  │ gateway of redirects      │ integer (32 bit) │\n├─────────┼───────────────────────────┼──────────────────┤\n│         │                           │                  │\n│mtu      │ MTU of path MTU discovery │ integer (16 bit) │\n└─────────┴───────────────────────────┴──────────────────┘\n\nIGMP HEADER EXPRESSION\nigmp {type | mrt | checksum | group}\n\nThis expression refers to IGMP header fields. When using it in inet, bridge or netdev\nfamilies, it will cause an implicit dependency on IPv4 to be created. To match on unusual\ncases like IGMP over IPv6, one has to add an explicit meta protocol ip6 match to the rule.\n"
                },
                {
                    "name": "Table 42. IGMP header expression",
                    "content": "┌─────────┬───────────────────────┬──────────────────┐\n│Keyword  │ Description           │ Type             │\n├─────────┼───────────────────────┼──────────────────┤\n│         │                       │                  │\n│type     │ IGMP type field       │ igmptype        │\n├─────────┼───────────────────────┼──────────────────┤\n│         │                       │                  │\n│mrt      │ IGMP maximum response │ integer (8 bit)  │\n│         │ time field            │                  │\n├─────────┼───────────────────────┼──────────────────┤\n│         │                       │                  │\n│checksum │ IGMP checksum field   │ integer (16 bit) │\n├─────────┼───────────────────────┼──────────────────┤\n│         │                       │                  │\n│group    │ Group address         │ integer (32 bit) │\n└─────────┴───────────────────────┴──────────────────┘\n\nIPV6 HEADER EXPRESSION\nip6 {version | dscp | ecn | flowlabel | length | nexthdr | hoplimit | saddr | daddr}\n\nThis expression refers to the ipv6 header fields. Caution when using ip6 nexthdr, the value\nonly refers to the next header, i.e. ip6 nexthdr tcp will only match if the ipv6 packet does\nnot contain any extension headers. Packets that are fragmented or e.g. contain a routing\nextension headers will not be matched. Please use meta l4proto if you wish to match the real\ntransport header and ignore any additional extension headers instead.\n"
                },
                {
                    "name": "Table 43. IPv6 header expression",
                    "content": "┌──────────┬─────────────────────────┬──────────────────┐\n│Keyword   │ Description             │ Type             │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│version   │ IP header version (6)   │ integer (4 bit)  │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│dscp      │ Differentiated Services │ dscp             │\n│          │ Code Point              │                  │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│ecn       │ Explicit Congestion     │ ecn              │\n│          │ Notification            │                  │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│flowlabel │ Flow label              │ integer (20 bit) │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│length    │ Payload length          │ integer (16 bit) │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│nexthdr   │ Nexthdr protocol        │ inetproto       │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│hoplimit  │ Hop limit               │ integer (8 bit)  │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│saddr     │ Source address          │ ipv6addr        │\n├──────────┼─────────────────────────┼──────────────────┤\n│          │                         │                  │\n│daddr     │ Destination address     │ ipv6addr        │\n└──────────┴─────────────────────────┴──────────────────┘\n\nUsing ip6 header expressions.\n\n# matching if first extension header indicates a fragment\nip6 nexthdr ipv6-frag\n\n\nICMPV6 HEADER EXPRESSION\nicmpv6 {type | code | checksum | parameter-problem | packet-too-big | id | sequence | max-delay}\n\nThis expression refers to ICMPv6 header fields. When using it in inet, bridge or netdev\nfamilies, it will cause an implicit dependency on IPv6 to be created. To match on unusual\ncases like ICMPv6 over IPv4, one has to add an explicit meta protocol ip match to the rule.\n"
                },
                {
                    "name": "Table 44. ICMPv6 header expression",
                    "content": "┌──────────────────┬───────────────────────────┬──────────────────┐\n│Keyword           │ Description               │ Type             │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│type              │ ICMPv6 type field         │ icmpv6type      │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│code              │ ICMPv6 code field         │ integer (8 bit)  │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│checksum          │ ICMPv6 checksum field     │ integer (16 bit) │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│parameter-problem │ pointer to problem        │ integer (32 bit) │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│packet-too-big    │ oversized MTU             │ integer (32 bit) │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│id                │ ID of echo                │ integer (16 bit) │\n│                  │ request/response          │                  │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│sequence          │ sequence number of echo   │ integer (16 bit) │\n│                  │ request/response          │                  │\n├──────────────────┼───────────────────────────┼──────────────────┤\n│                  │                           │                  │\n│max-delay         │ maximum response delay of │ integer (16 bit) │\n│                  │ MLD queries               │                  │\n└──────────────────┴───────────────────────────┴──────────────────┘\n\nTCP HEADER EXPRESSION\ntcp {sport | dport | sequence | ackseq | doff | reserved | flags | window | checksum | urgptr}\n"
                },
                {
                    "name": "Table 45. TCP header expression",
                    "content": "┌─────────┬────────────────────────┬───────────────────────┐\n│Keyword  │ Description            │ Type                  │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│sport    │ Source port            │ inetservice          │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│dport    │ Destination port       │ inetservice          │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│sequence │ Sequence number        │ integer (32 bit)      │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│ackseq   │ Acknowledgement number │ integer (32 bit)      │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│doff     │ Data offset            │ integer (4 bit) FIXME │\n│         │                        │ scaling               │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│reserved │ Reserved area          │ integer (4 bit)       │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│flags    │ TCP flags              │ tcpflag              │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│window   │ Window                 │ integer (16 bit)      │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│checksum │ Checksum               │ integer (16 bit)      │\n├─────────┼────────────────────────┼───────────────────────┤\n│         │                        │                       │\n│urgptr   │ Urgent pointer         │ integer (16 bit)      │\n└─────────┴────────────────────────┴───────────────────────┘\n\nUDP HEADER EXPRESSION\nudp {sport | dport | length | checksum}\n"
                },
                {
                    "name": "Table 46. UDP header expression",
                    "content": "┌─────────┬─────────────────────┬──────────────────┐\n│Keyword  │ Description         │ Type             │\n├─────────┼─────────────────────┼──────────────────┤\n│         │                     │                  │\n│sport    │ Source port         │ inetservice     │\n├─────────┼─────────────────────┼──────────────────┤\n│         │                     │                  │\n│dport    │ Destination port    │ inetservice     │\n├─────────┼─────────────────────┼──────────────────┤\n│         │                     │                  │\n│length   │ Total packet length │ integer (16 bit) │\n├─────────┼─────────────────────┼──────────────────┤\n│         │                     │                  │\n│checksum │ Checksum            │ integer (16 bit) │\n└─────────┴─────────────────────┴──────────────────┘\n\nUDP-LITE HEADER EXPRESSION\nudplite {sport | dport | checksum}\n"
                },
                {
                    "name": "Table 47. UDP-Lite header expression",
                    "content": "┌─────────┬──────────────────┬──────────────────┐\n│Keyword  │ Description      │ Type             │\n├─────────┼──────────────────┼──────────────────┤\n│         │                  │                  │\n│sport    │ Source port      │ inetservice     │\n├─────────┼──────────────────┼──────────────────┤\n│         │                  │                  │\n│dport    │ Destination port │ inetservice     │\n├─────────┼──────────────────┼──────────────────┤\n│         │                  │                  │\n│checksum │ Checksum         │ integer (16 bit) │\n└─────────┴──────────────────┴──────────────────┘\n\nSCTP HEADER EXPRESSION\nsctp {sport | dport | vtag | checksum}\nsctp chunk CHUNK [ FIELD ]\n\nCHUNK := data | init | init-ack | sack | heartbeat |\nheartbeat-ack | abort | shutdown | shutdown-ack | error |\ncookie-echo | cookie-ack | ecne | cwr | shutdown-complete\n| asconf-ack | forward-tsn | asconf\n\nFIELD := COMMONFIELD | DATAFIELD | INITFIELD | INITACKFIELD |\nSACKFIELD | SHUTDOWNFIELD | ECNEFIELD | CWRFIELD |\nASCONFACKFIELD | FORWARDTSNFIELD | ASCONFFIELD\n\nCOMMONFIELD := type | flags | length\nDATAFIELD := tsn | stream | ssn | ppid\nINITFIELD := init-tag | a-rwnd | num-outbound-streams |\nnum-inbound-streams | initial-tsn\nINITACKFIELD := INITFIELD\nSACKFIELD := cum-tsn-ack | a-rwnd | num-gap-ack-blocks |\nnum-dup-tsns\nSHUTDOWNFIELD := cum-tsn-ack\nECNEFIELD := lowest-tsn\nCWRFIELD := lowest-tsn\nASCONFACKFIELD := seqno\nFORWARDTSNFIELD := new-cum-tsn\nASCONFFIELD := seqno\n"
                },
                {
                    "name": "Table 48. SCTP header expression",
                    "content": "┌─────────┬────────────────────────┬────────────────────────┐\n│Keyword  │ Description            │ Type                   │\n├─────────┼────────────────────────┼────────────────────────┤\n│         │                        │                        │\n│sport    │ Source port            │ inetservice           │\n├─────────┼────────────────────────┼────────────────────────┤\n│         │                        │                        │\n│dport    │ Destination port       │ inetservice           │\n├─────────┼────────────────────────┼────────────────────────┤\n│         │                        │                        │\n│vtag     │ Verification Tag       │ integer (32 bit)       │\n├─────────┼────────────────────────┼────────────────────────┤\n│         │                        │                        │\n│checksum │ Checksum               │ integer (32 bit)       │\n├─────────┼────────────────────────┼────────────────────────┤\n│         │                        │                        │\n│chunk    │ Search chunk in packet │ without FIELD, boolean │\n│         │                        │ indicating existence   │\n└─────────┴────────────────────────┴────────────────────────┘\n"
                },
                {
                    "name": "Table 49. SCTP chunk fields",
                    "content": "┌─────────────────────┬───────────────┬──────────────────────┬──────────────────────┐\n│Name                 │ Width in bits │ Chunk                │ Notes                │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│type                 │ 8             │ all                  │ not useful, defined  │\n│                     │               │                      │ by chunk type        │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│flags                │ 8             │ all                  │ semantics defined on │\n│                     │               │                      │ per-chunk basis      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│length               │ 16            │ all                  │ length of this chunk │\n│                     │               │                      │ in bytes excluding   │\n│                     │               │                      │ padding              │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│tsn                  │ 32            │ data                 │ transmission         │\n│                     │               │                      │ sequence number      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│stream               │ 16            │ data                 │ stream identifier    │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│ssn                  │ 16            │ data                 │ stream sequence      │\n│                     │               │                      │ number               │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│ppid                 │ 32            │ data                 │ payload protocol     │\n│                     │               │                      │ identifier           │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│init-tag             │ 32            │ init, init-ack       │ initiate tag         │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│a-rwnd               │ 32            │ init, init-ack, sack │ advertised receiver  │\n│                     │               │                      │ window credit        │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│num-outbound-streams │ 16            │ init, init-ack       │ number of outbound   │\n│                     │               │                      │ streams              │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│num-inbound-streams  │ 16            │ init, init-ack       │ number of inbound    │\n│                     │               │                      │ streams              │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│initial-tsn          │ 32            │ init, init-ack       │ initial transmit     │\n│                     │               │                      │ sequence number      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│cum-tsn-ack          │ 32            │ sack, shutdown       │ cumulative           │\n│                     │               │                      │ transmission         │\n│                     │               │                      │ sequence number      │\n│                     │               │                      │ acknowledged         │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│num-gap-ack-blocks   │ 16            │ sack                 │ number of Gap Ack    │\n│                     │               │                      │ Blocks included      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│num-dup-tsns         │ 16            │ sack                 │ number of duplicate  │\n│                     │               │                      │ transmission         │\n│                     │               │                      │ sequence numbers     │\n│                     │               │                      │ received             │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│lowest-tsn           │ 32            │ ecne, cwr            │ lowest transmission  │\n│                     │               │                      │ sequence number      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│seqno                │ 32            │ asconf-ack, asconf   │ sequence number      │\n├─────────────────────┼───────────────┼──────────────────────┼──────────────────────┤\n│                     │               │                      │                      │\n│new-cum-tsn          │ 32            │ forward-tsn          │ new cumulative       │\n│                     │               │                      │ transmission         │\n│                     │               │                      │ sequence number      │\n└─────────────────────┴───────────────┴──────────────────────┴──────────────────────┘\n\nDCCP HEADER EXPRESSION\ndccp {sport | dport | type}\n"
                },
                {
                    "name": "Table 50. DCCP header expression",
                    "content": "┌────────┬──────────────────┬──────────────┐\n│Keyword │ Description      │ Type         │\n├────────┼──────────────────┼──────────────┤\n│        │                  │              │\n│sport   │ Source port      │ inetservice │\n├────────┼──────────────────┼──────────────┤\n│        │                  │              │\n│dport   │ Destination port │ inetservice │\n├────────┼──────────────────┼──────────────┤\n│        │                  │              │\n│type    │ Packet type      │ dccppkttype │\n└────────┴──────────────────┴──────────────┘\n\nAUTHENTICATION HEADER EXPRESSION\nah {nexthdr | hdrlength | reserved | spi | sequence}\n"
                },
                {
                    "name": "Table 51. AH header expression",
                    "content": "┌──────────┬──────────────────────────┬──────────────────┐\n│Keyword   │ Description              │ Type             │\n├──────────┼──────────────────────────┼──────────────────┤\n│          │                          │                  │\n│nexthdr   │ Next header protocol     │ inetproto       │\n├──────────┼──────────────────────────┼──────────────────┤\n│          │                          │                  │\n│hdrlength │ AH Header length         │ integer (8 bit)  │\n├──────────┼──────────────────────────┼──────────────────┤\n│          │                          │                  │\n│reserved  │ Reserved area            │ integer (16 bit) │\n├──────────┼──────────────────────────┼──────────────────┤\n│          │                          │                  │\n│spi       │ Security Parameter Index │ integer (32 bit) │\n├──────────┼──────────────────────────┼──────────────────┤\n│          │                          │                  │\n│sequence  │ Sequence number          │ integer (32 bit) │\n└──────────┴──────────────────────────┴──────────────────┘\n\nENCRYPTED SECURITY PAYLOAD HEADER EXPRESSION\nesp {spi | sequence}\n"
                },
                {
                    "name": "Table 52. ESP header expression",
                    "content": "┌─────────┬──────────────────────────┬──────────────────┐\n│Keyword  │ Description              │ Type             │\n├─────────┼──────────────────────────┼──────────────────┤\n│         │                          │                  │\n│spi      │ Security Parameter Index │ integer (32 bit) │\n├─────────┼──────────────────────────┼──────────────────┤\n│         │                          │                  │\n│sequence │ Sequence number          │ integer (32 bit) │\n└─────────┴──────────────────────────┴──────────────────┘\n\nIPCOMP HEADER EXPRESSION\ncomp {nexthdr | flags | cpi}\n"
                },
                {
                    "name": "Table 53. IPComp header expression",
                    "content": "┌────────┬───────────────────────┬──────────────────┐\n│Keyword │ Description           │ Type             │\n├────────┼───────────────────────┼──────────────────┤\n│        │                       │                  │\n│nexthdr │ Next header protocol  │ inetproto       │\n├────────┼───────────────────────┼──────────────────┤\n│        │                       │                  │\n│flags   │ Flags                 │ bitmask          │\n├────────┼───────────────────────┼──────────────────┤\n│        │                       │                  │\n│cpi     │ compression Parameter │ integer (16 bit) │\n│        │ Index                 │                  │\n└────────┴───────────────────────┴──────────────────┘\n\nRAW PAYLOAD EXPRESSION\n@base,offset,length\n\nThe raw payload expression instructs to load length bits starting at offset bits. Bit 0\nrefers to the very first bit — in the C programming language, this corresponds to the topmost\nbit, i.e. 0x80 in case of an octet. They are useful to match headers that do not have a\nhuman-readable template expression yet. Note that nft will not add dependencies for Raw\npayload expressions. If you e.g. want to match protocol fields of a transport header with\nprotocol number 5, you need to manually exclude packets that have a different transport\nheader, for instance by using meta l4proto 5 before the raw expression.\n"
                },
                {
                    "name": "Table 54. Supported payload protocol bases",
                    "content": "┌─────┬───────────────────────────────────┐\n│Base │ Description                       │\n├─────┼───────────────────────────────────┤\n│     │                                   │\n│ll   │ Link layer, for example the       │\n│     │ Ethernet header                   │\n├─────┼───────────────────────────────────┤\n│     │                                   │\n│nh   │ Network header, for example IPv4  │\n│     │ or IPv6                           │\n├─────┼───────────────────────────────────┤\n│     │                                   │\n│th   │ Transport Header, for example TCP │\n└─────┴───────────────────────────────────┘\n\nMatching destination port of both UDP and TCP.\n\ninet filter input meta l4proto {tcp, udp} @th,16,16 { 53, 80 }\n\nThe above can also be written as\n\ninet filter input meta l4proto {tcp, udp} th dport { 53, 80 }\n\nit is more convenient, but like the raw expression notation no dependencies are created or\nchecked. It is the users responsibility to restrict matching to those header types that have\na notion of ports. Otherwise, rules using raw expressions will errnously match unrelated\npackets, e.g. mis-interpreting ESP packets SPI field as a port.\n"
                },
                {
                    "name": "Rewrite arp packet target hardware address if target protocol address matches a given",
                    "content": "address.\n\ninput meta iifname enp2s0 arp ptype 0x0800 arp htype 1 arp hlen 6 arp plen 4 @nh,192,32 0xc0a88f10 @nh,144,48 set 0x112233445566 accept\n\n\nEXTENSION HEADER EXPRESSIONS\nExtension header expressions refer to data from variable-sized protocol headers, such as IPv6\nextension headers, TCP options and IPv4 options.\n\nnftables currently supports matching (finding) a given ipv6 extension header, TCP option or\nIPv4 option.\n\nhbh {nexthdr | hdrlength}\nfrag {nexthdr | frag-off | more-fragments | id}\nrt {nexthdr | hdrlength | type | seg-left}\ndst {nexthdr | hdrlength}\nmh {nexthdr | hdrlength | checksum | type}\nsrh {flags | tag | sid | seg-left}\ntcp option {eol | nop | maxseg | window | sack-perm | sack | sack0 | sack1 | sack2 | sack3 | timestamp} tcpoptionfield\nip option { lsrr | ra | rr | ssrr } ipoptionfield\n\nThe following syntaxes are valid only in a relational expression with boolean type on\nright-hand side for checking header existence only:\n\nexthdr {hbh | frag | rt | dst | mh}\ntcp option {eol | nop | maxseg | window | sack-perm | sack | sack0 | sack1 | sack2 | sack3 | timestamp}\nip option { lsrr | ra | rr | ssrr }\n"
                },
                {
                    "name": "Table 55. IPv6 extension headers",
                    "content": "┌────────┬────────────────────────┐\n│Keyword │ Description            │\n├────────┼────────────────────────┤\n│        │                        │\n│hbh     │ Hop by Hop             │\n├────────┼────────────────────────┤\n│        │                        │\n│rt      │ Routing Header         │\n├────────┼────────────────────────┤\n│        │                        │\n│frag    │ Fragmentation header   │\n├────────┼────────────────────────┤\n│        │                        │\n│dst     │ dst options            │\n├────────┼────────────────────────┤\n│        │                        │\n│mh      │ Mobility Header        │\n├────────┼────────────────────────┤\n│        │                        │\n│srh     │ Segment Routing Header │\n└────────┴────────────────────────┘\n"
                },
                {
                    "name": "Table 56. TCP Options",
                    "content": "┌──────────┬───────────────────────────┬──────────────────────┐\n│Keyword   │ Description               │ TCP option fields    │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│eol       │ End if option list        │ -                    │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│nop       │ 1 Byte TCP Nop padding    │ -                    │\n│          │ option                    │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│maxseg    │ TCP Maximum Segment Size  │ length, size         │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│window    │ TCP Window Scaling        │ length, count        │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack-perm │ TCP SACK permitted        │ length               │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack      │ TCP Selective             │ length, left, right  │\n│          │ Acknowledgement (alias of │                      │\n│          │ block 0)                  │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack0     │ TCP Selective             │ length, left, right  │\n│          │ Acknowledgement (block 0) │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack1     │ TCP Selective             │ length, left, right  │\n│          │ Acknowledgement (block 1) │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack2     │ TCP Selective             │ length, left, right  │\n│          │ Acknowledgement (block 2) │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│sack3     │ TCP Selective             │ length, left, right  │\n│          │ Acknowledgement (block 3) │                      │\n├──────────┼───────────────────────────┼──────────────────────┤\n│          │                           │                      │\n│timestamp │ TCP Timestamps            │ length, tsval, tsecr │\n└──────────┴───────────────────────────┴──────────────────────┘\n\nTCP option matching also supports raw expression syntax to access arbitrary options:\n\ntcp option\n\ntcp option @number,offset,length\n"
                },
                {
                    "name": "Table 57. IP Options",
                    "content": "┌────────┬─────────────────────┬─────────────────────────┐\n│Keyword │ Description         │ IP option fields        │\n├────────┼─────────────────────┼─────────────────────────┤\n│        │                     │                         │\n│lsrr    │ Loose Source Route  │ type, length, ptr, addr │\n├────────┼─────────────────────┼─────────────────────────┤\n│        │                     │                         │\n│ra      │ Router Alert        │ type, length, value     │\n├────────┼─────────────────────┼─────────────────────────┤\n│        │                     │                         │\n│rr      │ Record Route        │ type, length, ptr, addr │\n├────────┼─────────────────────┼─────────────────────────┤\n│        │                     │                         │\n│ssrr    │ Strict Source Route │ type, length, ptr, addr │\n└────────┴─────────────────────┴─────────────────────────┘\n\nfinding TCP options.\n\nfilter input tcp option sack-perm exists counter\n\nmatching TCP options.\n\nfilter input tcp option maxseg size lt 536\n\nmatching IPv6 exthdr.\n\nip6 filter input frag more-fragments 1 counter\n\nfinding IP option.\n\nfilter input ip option lsrr exists counter\n\n\nCONNTRACK EXPRESSIONS\nConntrack expressions refer to meta data of the connection tracking entry associated with a\npacket.\n\nThere are three types of conntrack expressions. Some conntrack expressions require the flow\ndirection before the conntrack key, others must be used directly because they are direction\nagnostic. The packets, bytes and avgpkt keywords can be used with or without a direction. If\nthe direction is omitted, the sum of the original and the reply direction is returned. The\nsame is true for the zone, if a direction is given, the zone is only matched if the zone id\nis tied to the given direction.\n\nct {state | direction | status | mark | expiration | helper | label | count | id}\nct [original | reply] {l3proto | protocol | bytes | packets | avgpkt | zone}\nct {original | reply} {proto-src | proto-dst}\nct {original | reply} {ip | ip6} {saddr | daddr}\n\nThe conntrack-specific types in this table are described in the sub-section CONNTRACK TYPES\nabove.\n"
                },
                {
                    "name": "Table 58. Conntrack expressions",
                    "content": "┌───────────┬───────────────────────────┬─────────────────────┐\n│Keyword    │ Description               │ Type                │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│state      │ State of the connection   │ ctstate            │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│direction  │ Direction of the packet   │ ctdir              │\n│           │ relative to the           │                     │\n│           │ connection                │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│status     │ Status of the connection  │ ctstatus           │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│mark       │ Connection mark           │ mark                │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│expiration │ Connection expiration     │ time                │\n│           │ time                      │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│helper     │ Helper associated with    │ string              │\n│           │ the connection            │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│label      │ Connection tracking label │ ctlabel            │\n│           │ bit or symbolic name      │                     │\n│           │ defined in connlabel.conf │                     │\n│           │ in the nftables include   │                     │\n│           │ path                      │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│l3proto    │ Layer 3 protocol of the   │ nfproto            │\n│           │ connection                │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│saddr      │ Source address of the     │ ipv4addr/ipv6addr │\n│           │ connection for the given  │                     │\n│           │ direction                 │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│daddr      │ Destination address of    │ ipv4addr/ipv6addr │\n│           │ the connection for the    │                     │\n│           │ given direction           │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│protocol   │ Layer 4 protocol of the   │ inetproto          │\n│           │ connection for the given  │                     │\n│           │ direction                 │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│proto-src  │ Layer 4 protocol source   │ integer (16 bit)    │\n│           │ for the given direction   │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│proto-dst  │ Layer 4 protocol          │ integer (16 bit)    │\n│           │ destination for the given │                     │\n│           │ direction                 │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│packets    │ packet count seen in the  │ integer (64 bit)    │\n│           │ given direction or sum of │                     │\n│           │ original and reply        │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│bytes      │ byte count seen, see      │ integer (64 bit)    │\n│           │ description for packets   │                     │\n│           │ keyword                   │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│avgpkt     │ average bytes per packet, │ integer (64 bit)    │\n│           │ see description for       │                     │\n│           │ packets keyword           │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│zone       │ conntrack zone            │ integer (16 bit)    │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│count      │ number of current         │ integer (32 bit)    │\n│           │ connections               │                     │\n├───────────┼───────────────────────────┼─────────────────────┤\n│           │                           │                     │\n│id         │ Connection id             │ ctid               │\n└───────────┴───────────────────────────┴─────────────────────┘\n\nrestrict the number of parallel connections to a server.\n\nnft add set filter sshflood '{ type ipv4addr; flags dynamic; }'\nnft add rule filter input tcp dport 22 add @sshflood '{ ip saddr ct count over 2 }' reject\n\n"
                }
            ]
        },
        "STATEMENTS": {
            "content": "Statements represent actions to be performed. They can alter control flow (return, jump to a\ndifferent chain, accept or drop the packet) or can perform actions, such as logging,\nrejecting a packet, etc.\n\nStatements exist in two kinds. Terminal statements unconditionally terminate evaluation of\nthe current rule, non-terminal statements either only conditionally or never terminate\nevaluation of the current rule, in other words, they are passive from the ruleset evaluation\nperspective. There can be an arbitrary amount of non-terminal statements in a rule, but only\na single terminal statement as the final statement.\n\nVERDICT STATEMENT\nThe verdict statement alters control flow in the ruleset and issues policy decisions for\npackets.\n\n{accept | drop | queue | continue | return}\n{jump | goto} chain\n\naccept and drop are absolute verdicts — they terminate ruleset evaluation immediately.\n\n\naccept       Terminate ruleset evaluation and\naccept the packet. The packet can\nstill be dropped later by another\nhook, for instance accept in the\nforward hook still allows to drop\nthe packet later in the\npostrouting hook, or another\nforward base chain that has a\nhigher priority number and is\nevaluated afterwards in the\nprocessing pipeline.\n\ndrop         Terminate ruleset evaluation and\ndrop the packet. The drop occurs\ninstantly, no further chains or\nhooks are evaluated. It is not\npossible to accept the packet in\na later chain again, as those are\nnot evaluated anymore for the\npacket.\n\nqueue        Terminate ruleset evaluation and\nqueue the packet to userspace.\nUserspace must provide a drop or\naccept verdict. In case of\naccept, processing resumes with\nthe next base chain hook, not the\nrule following the queue verdict.\n\ncontinue     Continue ruleset evaluation with\nthe next rule. This is the\ndefault behaviour in case a rule\nissues no verdict.\n\nreturn       Return from the current chain and\ncontinue evaluation at the next\nrule in the last chain. If issued\nin a base chain, it is equivalent\nto the base chain policy.\n\njump chain   Continue evaluation at the first\nrule in chain. The current\nposition in the ruleset is pushed\nto a call stack and evaluation\nwill continue there when the new\nchain is entirely evaluated or a\nreturn verdict is issued. In case\nan absolute verdict is issued by\na rule in the chain, ruleset\nevaluation terminates immediately\nand the specific action is taken.\n\ngoto chain   Similar to jump, but the current\nposition is not pushed to the\ncall stack, meaning that after\nthe new chain evaluation will\ncontinue at the last chain\ninstead of the one containing the\ngoto statement.\n\n\nUsing verdict statements.\n\n# process packets from eth0 and the internal network in fromlan\n# chain, drop all packets from eth0 with different source addresses.\n\nfilter input iif eth0 ip saddr 192.168.0.0/24 jump fromlan\nfilter input iif eth0 drop\n\n\nPAYLOAD STATEMENT\npayloadexpression set value\n\nThe payload statement alters packet content. It can be used for example to set ip DSCP\n(diffserv) header field or ipv6 flow labels.\n\nroute some packets instead of bridging.\n\n# redirect tcp:http from 192.160.0.0/16 to local machine for routing instead of bridging\n# assumes 00:11:22:33:44:55 is local MAC address.\nbridge input meta iif eth0 ip saddr 192.168.0.0/16 tcp dport 80 meta pkttype set unicast ether daddr set 00:11:22:33:44:55\n\nSet IPv4 DSCP header field.\n\nip forward ip dscp set 42\n\n\nEXTENSION HEADER STATEMENT\nextensionheaderexpression set value\n\nThe extension header statement alters packet content in variable-sized headers. This can\ncurrently be used to alter the TCP Maximum segment size of packets, similar to TCPMSS.\n\nchange tcp mss.\n\ntcp flags syn tcp option maxseg size set 1360\n# set a size based on route information:\ntcp flags syn tcp option maxseg size set rt mtu\n\n\nLOG STATEMENT\nlog [prefix quotedstring] [level syslog-level] [flags log-flags]\nlog group nfloggroup [prefix quotedstring] [queue-threshold value] [snaplen size]\nlog level audit\n\nThe log statement enables logging of matching packets. When this statement is used from a\nrule, the Linux kernel will print some information on all matching packets, such as header\nfields, via the kernel log (where it can be read with dmesg(1) or read in the syslog).\n\nIn the second form of invocation (if nfloggroup is specified), the Linux kernel will pass\nthe packet to nfnetlinklog which will send the log through a netlink socket to the specified\ngroup. One userspace process may subscribe to the group to receive the logs, see man(8) ulogd\nfor the Netfilter userspace log daemon and libnetfilterlog documentation for details in case\nyou would like to develop a custom program to digest your logs.\n\nIn the third form of invocation (if level audit is specified), the Linux kernel writes a\nmessage into the audit buffer suitably formatted for reading with auditd. Therefore no\nfurther formatting options (such as prefix or flags) are allowed in this mode.\n\nThis is a non-terminating statement, so the rule evaluation continues after the packet is\nlogged.\n",
            "subsections": [
                {
                    "name": "Table 59. log statement options",
                    "content": "┌────────────────┬──────────────────────────┬───────────────────────────┐\n│Keyword         │ Description              │ Type                      │\n├────────────────┼──────────────────────────┼───────────────────────────┤\n│                │                          │                           │\n│prefix          │ Log message prefix       │ quoted string             │\n├────────────────┼──────────────────────────┼───────────────────────────┤\n│                │                          │                           │\n│level           │ Syslog level of logging  │ string: emerg, alert,     │\n│                │                          │ crit, err, warn           │\n│                │                          │ [default], notice, info,  │\n│                │                          │ debug, audit              │\n├────────────────┼──────────────────────────┼───────────────────────────┤\n│                │                          │                           │\n│group           │ NFLOG group to send      │ unsigned integer (16 bit) │\n│                │ messages to              │                           │\n├────────────────┼──────────────────────────┼───────────────────────────┤\n│                │                          │                           │\n│snaplen         │ Length of packet payload │ unsigned integer (32 bit) │\n│                │ to include in netlink    │                           │\n│                │ message                  │                           │\n├────────────────┼──────────────────────────┼───────────────────────────┤\n│                │                          │                           │\n│queue-threshold │ Number of packets to     │ unsigned integer (32 bit) │\n│                │ queue inside the kernel  │                           │\n│                │ before sending them to   │                           │\n│                │ userspace                │                           │\n└────────────────┴──────────────────────────┴───────────────────────────┘\n"
                },
                {
                    "name": "Table 60. log-flags",
                    "content": "┌─────────────┬─────────────────────────────────┐\n│Flag         │ Description                     │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│tcp sequence │ Log TCP sequence numbers.       │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│tcp options  │ Log options from the TCP packet │\n│             │ header.                         │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│ip options   │ Log options from the IP/IPv6    │\n│             │ packet header.                  │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│skuid        │ Log the userid of the process   │\n│             │ which generated the packet.     │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│ether        │ Decode MAC addresses and        │\n│             │ protocol.                       │\n├─────────────┼─────────────────────────────────┤\n│             │                                 │\n│all          │ Enable all log flags listed     │\n│             │ above.                          │\n└─────────────┴─────────────────────────────────┘\n\nUsing log statement.\n\n# log the UID which generated the packet and ip options\nip filter output log flags skuid flags ip options\n\n# log the tcp sequence numbers and tcp options from the TCP packet\nip filter output log flags tcp sequence,options\n\n# enable all supported log flags\nip6 filter output log flags all\n\n\nREJECT STATEMENT\nreject [ with REJECTWITH ]\n\nREJECTWITH := icmp icmpcode |\nicmpv6 icmpv6code |\nicmpx icmpxcode |\ntcp reset\n\nA reject statement is used to send back an error packet in response to the matched packet\notherwise it is equivalent to drop so it is a terminating statement, ending rule traversal.\nThis statement is only valid in base chains using the input, forward or output hooks, and\nuser-defined chains which are only called from those chains.\n"
                },
                {
                    "name": "Table 61. different ICMP reject variants are meant for use in different table families",
                    "content": "┌────────┬────────┬─────────────┐\n│Variant │ Family │ Type        │\n├────────┼────────┼─────────────┤\n│        │        │             │\n│icmp    │ ip     │ icmpcode   │\n├────────┼────────┼─────────────┤\n│        │        │             │\n│icmpv6  │ ip6    │ icmpv6code │\n├────────┼────────┼─────────────┤\n│        │        │             │\n│icmpx   │ inet   │ icmpxcode  │\n└────────┴────────┴─────────────┘\n\nFor a description of the different types and a list of supported keywords refer to DATA TYPES\nsection above. The common default reject value is port-unreachable.\n\nNote that in bridge family, reject statement is only allowed in base chains which hook into\ninput or prerouting.\n\nCOUNTER STATEMENT\nA counter statement sets the hit count of packets along with the number of bytes.\n\ncounter packets number bytes number\ncounter { packets number | bytes number }\n\nCONNTRACK STATEMENT\nThe conntrack statement can be used to set the conntrack mark and conntrack labels.\n\nct {mark | event | label | zone} set value\n\nThe ct statement sets meta data associated with a connection. The zone id has to be assigned\nbefore a conntrack lookup takes place, i.e. this has to be done in prerouting and possibly\noutput (if locally generated packets need to be placed in a distinct zone), with a hook\npriority of raw (-300).\n\nUnlike iptables, where the helper assignment happens in the raw table, the helper needs to be\nassigned after a conntrack entry has been found, i.e. it will not work when used with hook\npriorities equal or before -200.\n"
                },
                {
                    "name": "Table 62. Conntrack statement types",
                    "content": "┌────────┬───────────────────────────┬───────────────────────────┐\n│Keyword │ Description               │ Value                     │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│event   │ conntrack event bits      │ bitmask, integer (32 bit) │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│helper  │ name of ct helper object  │ quoted string             │\n│        │ to assign to the          │                           │\n│        │ connection                │                           │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│mark    │ Connection tracking mark  │ mark                      │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│label   │ Connection tracking label │ label                     │\n├────────┼───────────────────────────┼───────────────────────────┤\n│        │                           │                           │\n│zone    │ conntrack zone            │ integer (16 bit)          │\n└────────┴───────────────────────────┴───────────────────────────┘\n\nsave packet nfmark in conntrack.\n\nct mark set meta mark\n\nset zone mapped via interface.\n\ntable inet raw {\nchain prerouting {\ntype filter hook prerouting priority raw;\nct zone set iif map { \"eth1\" : 1, \"veth1\" : 2 }\n}\nchain output {\ntype filter hook output priority raw;\nct zone set oif map { \"eth1\" : 1, \"veth1\" : 2 }\n}\n}\n\nrestrict events reported by ctnetlink.\n\nct event set new,related,destroy\n\n\nNOTRACK STATEMENT\nThe notrack statement allows to disable connection tracking for certain packets.\n\nnotrack\n\nNote that for this statement to be effective, it has to be applied to packets before a\nconntrack lookup happens. Therefore, it needs to sit in a chain with either prerouting or\noutput hook and a hook priority of -300 (raw) or less.\n\nSee SYNPROXY STATEMENT for an example usage.\n\nMETA STATEMENT\nA meta statement sets the value of a meta expression. The existing meta fields are: priority,\nmark, pkttype, nftrace.\n\nmeta {mark | priority | pkttype | nftrace} set value\n\nA meta statement sets meta data associated with a packet.\n"
                },
                {
                    "name": "Table 63. Meta statement types",
                    "content": "┌─────────┬───────────────────────────┬───────────┐\n│Keyword  │ Description               │ Value     │\n├─────────┼───────────────────────────┼───────────┤\n│         │                           │           │\n│priority │ TC packet priority        │ tchandle │\n├─────────┼───────────────────────────┼───────────┤\n│         │                           │           │\n│mark     │ Packet mark               │ mark      │\n├─────────┼───────────────────────────┼───────────┤\n│         │                           │           │\n│pkttype  │ packet type               │ pkttype  │\n├─────────┼───────────────────────────┼───────────┤\n│         │                           │           │\n│nftrace  │ ruleset packet tracing    │ 0, 1      │\n│         │ on/off. Use monitor trace │           │\n│         │ command to watch traces   │           │\n└─────────┴───────────────────────────┴───────────┘\n\nLIMIT STATEMENT\nlimit rate [over] packetnumber / TIMEUNIT [burst packetnumber packets]\nlimit rate [over] bytenumber BYTEUNIT / TIMEUNIT [burst bytenumber BYTEUNIT]\n\nTIMEUNIT := second | minute | hour | day\nBYTEUNIT := bytes | kbytes | mbytes\n\nA limit statement matches at a limited rate using a token bucket filter. A rule using this\nstatement will match until this limit is reached. It can be used in combination with the log\nstatement to give limited logging. The optional over keyword makes it match over the\nspecified rate. Default burst is 5. if you specify burst, it must be non-zero value.\n"
                },
                {
                    "name": "Table 64. limit statement values",
                    "content": "┌──────────────┬───────────────────┬───────────────────────────┐\n│Value         │ Description       │ Type                      │\n├──────────────┼───────────────────┼───────────────────────────┤\n│              │                   │                           │\n│packetnumber │ Number of packets │ unsigned integer (32 bit) │\n├──────────────┼───────────────────┼───────────────────────────┤\n│              │                   │                           │\n│bytenumber   │ Number of bytes   │ unsigned integer (32 bit) │\n└──────────────┴───────────────────┴───────────────────────────┘\n\nNAT STATEMENTS\nsnat [[ip | ip6] to] ADDRSPEC [:PORTSPEC] [FLAGS]\ndnat [[ip | ip6] to] ADDRSPEC [:PORTSPEC] [FLAGS]\nmasquerade [to :PORTSPEC] [FLAGS]\nredirect [to :PORTSPEC] [FLAGS]\n\nADDRSPEC := address | address - address\nPORTSPEC := port | port - port\n\nFLAGS  := FLAG [, FLAGS]\nFLAG  := persistent | random | fully-random\n\nThe nat statements are only valid from nat chain types.\n\nThe snat and masquerade statements specify that the source address of the packet should be\nmodified. While snat is only valid in the postrouting and input chains, masquerade makes\nsense only in postrouting. The dnat and redirect statements are only valid in the prerouting\nand output chains, they specify that the destination address of the packet should be\nmodified. You can use non-base chains which are called from base chains of nat chain type\ntoo. All future packets in this connection will also be mangled, and rules should cease being\nexamined.\n\nThe masquerade statement is a special form of snat which always uses the outgoing interface’s\nIP address to translate to. It is particularly useful on gateways with dynamic (public) IP\naddresses.\n\nThe redirect statement is a special form of dnat which always translates the destination\naddress to the local host’s one. It comes in handy if one only wants to alter the destination\nport of incoming traffic on different interfaces.\n\nWhen used in the inet family (available with kernel 5.2), the dnat and snat statements\nrequire the use of the ip and ip6 keyword in case an address is provided, see the examples\nbelow.\n\nBefore kernel 4.18 nat statements require both prerouting and postrouting base chains to be\npresent since otherwise packets on the return path won’t be seen by netfilter and therefore\nno reverse translation will take place.\n"
                },
                {
                    "name": "Table 65. NAT statement values",
                    "content": "┌───────────┬──────────────────────────┬─────────────────────────┐\n│Expression │ Description              │ Type                    │\n├───────────┼──────────────────────────┼─────────────────────────┤\n│           │                          │                         │\n│address    │ Specifies that the       │ ipv4addr, ipv6addr,   │\n│           │ source/destination       │ e.g. abcd::1234, or you │\n│           │ address of the packet    │ can use a mapping, e.g. │\n│           │ should be modified. You  │ meta mark map { 10 :    │\n│           │ may specify a mapping to │ 192.168.1.2, 20 :       │\n│           │ relate a list of tuples  │ 192.168.1.3 }           │\n│           │ composed of arbitrary    │                         │\n│           │ expression key with      │                         │\n│           │ address value.           │                         │\n├───────────┼──────────────────────────┼─────────────────────────┤\n│           │                          │                         │\n│port       │ Specifies that the       │ port number (16 bit)    │\n│           │ source/destination       │                         │\n│           │ address of the packet    │                         │\n│           │ should be modified.      │                         │\n└───────────┴──────────────────────────┴─────────────────────────┘\n"
                },
                {
                    "name": "Table 66. NAT statement flags",
                    "content": "┌─────────────┬───────────────────────────────────┐\n│Flag         │ Description                       │\n├─────────────┼───────────────────────────────────┤\n│             │                                   │\n│persistent   │ Gives a client the same           │\n│             │ source-/destination-address for   │\n│             │ each connection.                  │\n├─────────────┼───────────────────────────────────┤\n│             │                                   │\n│random       │ In kernel 5.0 and newer this is   │\n│             │ the same as fully-random. In      │\n│             │ earlier kernels the port mapping  │\n│             │ will be randomized using a seeded │\n│             │ MD5 hash mix using source and     │\n│             │ destination address and           │\n│             │ destination port.                 │\n├─────────────┼───────────────────────────────────┤\n│             │                                   │\n│fully-random │ If used then port mapping is      │\n│             │ generated based on a 32-bit       │\n│             │ pseudo-random algorithm.          │\n└─────────────┴───────────────────────────────────┘\n\nUsing NAT statements.\n\n# create a suitable table/chain setup for all further examples\nadd table nat\nadd chain nat prerouting { type nat hook prerouting priority dstnat; }\nadd chain nat postrouting { type nat hook postrouting priority srcnat; }\n\n# translate source addresses of all packets leaving via eth0 to address 1.2.3.4\nadd rule nat postrouting oif eth0 snat to 1.2.3.4\n\n# redirect all traffic entering via eth0 to destination address 192.168.1.120\nadd rule nat prerouting iif eth0 dnat to 192.168.1.120\n\n# translate source addresses of all packets leaving via eth0 to whatever\n# locally generated packets would use as source to reach the same destination\nadd rule nat postrouting oif eth0 masquerade\n\n# redirect incoming TCP traffic for port 22 to port 2222\nadd rule nat prerouting tcp dport 22 redirect to :2222\n\n# inet family:\n# handle ip dnat:\nadd rule inet nat prerouting dnat ip to 10.0.2.99\n# handle ip6 dnat:\nadd rule inet nat prerouting dnat ip6 to fe80::dead\n# this masquerades both ipv4 and ipv6:\nadd rule inet nat postrouting meta oif ppp0 masquerade\n\n\nTPROXY STATEMENT\nTproxy redirects the packet to a local socket without changing the packet header in any way.\nIf any of the arguments is missing the data of the incoming packet is used as parameter.\nTproxy matching requires another rule that ensures the presence of transport protocol header\nis specified.\n\ntproxy to address:port\ntproxy to {address | :port}\n\nThis syntax can be used in ip/ip6 tables where network layer protocol is obvious. Either IP\naddress or port can be specified, but at least one of them is necessary.\n\ntproxy {ip | ip6} to address[:port]\ntproxy to :port\n\nThis syntax can be used in inet tables. The ip/ip6 parameter defines the family the rule will\nmatch. The address parameter must be of this family. When only port is defined, the address\nfamily should not be specified. In this case the rule will match for both families.\n"
                },
                {
                    "name": "Table 67. tproxy attributes",
                    "content": "┌────────┬─────────────────────────────────┐\n│Name    │ Description                     │\n├────────┼─────────────────────────────────┤\n│        │                                 │\n│address │ IP address the listening socket │\n│        │ with IPTRANSPARENT option is   │\n│        │ bound to.                       │\n├────────┼─────────────────────────────────┤\n│        │                                 │\n│port    │ Port the listening socket with  │\n│        │ IPTRANSPARENT option is bound  │\n│        │ to.                             │\n└────────┴─────────────────────────────────┘\n\nExample ruleset for tproxy statement.\n\ntable ip x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\ntcp dport ntp tproxy to 1.1.1.1\nudp dport ssh tproxy to :2222\n}\n}\ntable ip6 x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\ntcp dport ntp tproxy to [dead::beef]\nudp dport ssh tproxy to :2222\n}\n}\ntable inet x {\nchain y {\ntype filter hook prerouting priority mangle; policy accept;\ntcp dport 321 tproxy to :ssh\ntcp dport 99 tproxy ip to 1.1.1.1:999\nudp dport 155 tproxy ip6 to [dead::beef]:smux\n}\n}\n\n\nSYNPROXY STATEMENT\nThis statement will process TCP three-way-handshake parallel in netfilter context to protect\neither local or backend system. This statement requires connection tracking because sequence\nnumbers need to be translated.\n\nsynproxy [mss mssvalue] [wscale wscalevalue] [SYNPROXYFLAGS]\n"
                },
                {
                    "name": "Table 68. synproxy statement attributes",
                    "content": "┌───────┬───────────────────────────────────┐\n│Name   │ Description                       │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│mss    │ Maximum segment size announced to │\n│       │ clients. This must match the      │\n│       │ backend.                          │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│wscale │ Window scale announced to         │\n│       │ clients. This must match the      │\n│       │ backend.                          │\n└───────┴───────────────────────────────────┘\n"
                },
                {
                    "name": "Table 69. synproxy statement flags",
                    "content": "┌──────────┬───────────────────────────────────┐\n│Flag      │ Description                       │\n├──────────┼───────────────────────────────────┤\n│          │                                   │\n│sack-perm │ Pass client selective             │\n│          │ acknowledgement option to backend │\n│          │ (will be disabled if not          │\n│          │ present).                         │\n├──────────┼───────────────────────────────────┤\n│          │                                   │\n│timestamp │ Pass client timestamp option to   │\n│          │ backend (will be disabled if not  │\n│          │ present, also needed for          │\n│          │ selective acknowledgement and     │\n│          │ window scaling).                  │\n└──────────┴───────────────────────────────────┘\n\nExample ruleset for synproxy statement.\n\nDetermine tcp options used by backend, from an external system\n\ntcpdump -pni eth0 -c 1 'tcp[tcpflags] == (tcp-syn|tcp-ack)'\nport 80 &\ntelnet 192.0.2.42 80\n18:57:24.693307 IP 192.0.2.42.80 > 192.0.2.43.48757:\nFlags [S.], seq 360414582, ack 788841994, win 14480,\noptions [mss 1460,sackOK,\nTS val 1409056151 ecr 9690221,\nnop,wscale 9],\nlength 0\n\nSwitch tcploose mode off, so conntrack will mark out-of-flow packets as state INVALID.\n\necho 0 > /proc/sys/net/netfilter/nfconntracktcploose\n\nMake SYN packets untracked.\n\ntable ip x {\nchain y {\ntype filter hook prerouting priority raw; policy accept;\ntcp flags syn notrack\n}\n}\n\nCatch UNTRACKED (SYN  packets) and INVALID (3WHS ACK packets) states and send\nthem to SYNPROXY. This rule will respond to SYN packets with SYN+ACK\nsyncookies, create ESTABLISHED for valid client response (3WHS ACK packets) and\ndrop incorrect cookies. Flags combinations not expected during  3WHS will not\nmatch and continue (e.g. SYN+FIN, SYN+ACK). Finally, drop invalid packets, this\nwill be out-of-flow packets that were not matched by SYNPROXY.\n\ntable ip x {\nchain z {\ntype filter hook input priority filter; policy accept;\nct state invalid, untracked synproxy mss 1460 wscale 9 timestamp sack-perm\nct state invalid drop\n}\n}\n\n\nFLOW STATEMENT\nA flow statement allows us to select what flows you want to accelerate forwarding through\nlayer 3 network stack bypass. You have to specify the flowtable name where you want to\noffload this flow.\n\nflow add @flowtable\n\nQUEUE STATEMENT\nThis statement passes the packet to userspace using the nfnetlinkqueue handler. The packet\nis put into the queue identified by its 16-bit queue number. Userspace can inspect and modify\nthe packet if desired. Userspace must then drop or re-inject the packet into the kernel. See\nlibnetfilterqueue documentation for details.\n\nqueue [flags QUEUEFLAGS] [to queuenumber]\nqueue [flags QUEUEFLAGS] [to queuenumberfrom - queuenumberto]\nqueue [flags QUEUEFLAGS] [to QUEUEEXPRESSION ]\n\nQUEUEFLAGS := QUEUEFLAG [, QUEUEFLAGS]\nQUEUEFLAG  := bypass | fanout\nQUEUEEXPRESSION := numgen | hash | symhash | MAP STATEMENT\n\nQUEUEEXPRESSION can be used to compute a queue number at run-time with the hash or numgen\nexpressions. It also allows to use the map statement to assign fixed queue numbers based on\nexternal inputs such as the source ip address or interface names.\n"
                },
                {
                    "name": "Table 70. queue statement values",
                    "content": "┌──────────────────┬───────────────────────────┬───────────────────────────┐\n│Value             │ Description               │ Type                      │\n├──────────────────┼───────────────────────────┼───────────────────────────┤\n│                  │                           │                           │\n│queuenumber      │ Sets queue number,        │ unsigned integer (16 bit) │\n│                  │ default is 0.             │                           │\n├──────────────────┼───────────────────────────┼───────────────────────────┤\n│                  │                           │                           │\n│queuenumberfrom │ Sets initial queue in the │ unsigned integer (16 bit) │\n│                  │ range, if fanout is used. │                           │\n├──────────────────┼───────────────────────────┼───────────────────────────┤\n│                  │                           │                           │\n│queuenumberto   │ Sets closing queue in the │ unsigned integer (16 bit) │\n│                  │ range, if fanout is used. │                           │\n└──────────────────┴───────────────────────────┴───────────────────────────┘\n"
                },
                {
                    "name": "Table 71. queue statement flags",
                    "content": "┌───────┬───────────────────────────────────┐\n│Flag   │ Description                       │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│bypass │ Let packets go through if         │\n│       │ userspace application cannot back │\n│       │ off. Before using this flag, read │\n│       │ libnetfilterqueue documentation  │\n│       │ for performance tuning            │\n│       │ recommendations.                  │\n├───────┼───────────────────────────────────┤\n│       │                                   │\n│fanout │ Distribute packets between        │\n│       │ several queues.                   │\n└───────┴───────────────────────────────────┘\n\nDUP STATEMENT\nThe dup statement is used to duplicate a packet and send the copy to a different destination.\n\ndup to device\ndup to address device device\n"
                },
                {
                    "name": "Table 72. Dup statement values",
                    "content": "┌───────────┬───────────────────────────┬──────────────────────────┐\n│Expression │ Description               │ Type                     │\n├───────────┼───────────────────────────┼──────────────────────────┤\n│           │                           │                          │\n│address    │ Specifies that the copy   │ ipv4addr, ipv6addr,    │\n│           │ of the packet should be   │ e.g. abcd::1234, or you  │\n│           │ sent to a new gateway.    │ can use a mapping, e.g.  │\n│           │                           │ ip saddr map {           │\n│           │                           │ 192.168.1.2 : 10.1.1.1 } │\n├───────────┼───────────────────────────┼──────────────────────────┤\n│           │                           │                          │\n│device     │ Specifies that the copy   │ string                   │\n│           │ should be transmitted via │                          │\n│           │ device.                   │                          │\n└───────────┴───────────────────────────┴──────────────────────────┘\n\nUsing the dup statement.\n\n# send to machine with ip address 10.2.3.4 on eth0\nip filter forward dup to 10.2.3.4 device \"eth0\"\n\n# copy raw frame to another interface\nnetdev ingress dup to \"eth0\"\ndup to \"eth0\"\n\n# combine with map dst addr to gateways\ndup to ip daddr map { 192.168.7.1 : \"eth0\", 192.168.7.2 : \"eth1\" }\n\n\nFWD STATEMENT\nThe fwd statement is used to redirect a raw packet to another interface. It is only available\nin the netdev family ingress and egress hooks. It is similar to the dup statement except that\nno copy is made.\n\nfwd to device\n\nSET STATEMENT\nThe set statement is used to dynamically add or update elements in a set from the packet\npath. The set setname must already exist in the given table and must have been created with\none or both of the dynamic and the timeout flags. The dynamic flag is required if the set\nstatement expression includes a stateful object. The timeout flag is implied if the set is\ncreated with a timeout, and is required if the set statement updates elements, rather than\nadding them. Furthermore, these sets should specify both a maximum set size (to prevent\nmemory exhaustion), and their elements should have a timeout (so their number will not grow\nindefinitely) either from the set definition or from the statement that adds or updates them.\nThe set statement can be used to e.g. create dynamic blacklists.\n\n{add | update} @setname { expression [timeout timeout] [comment string] }\n\nExample for simple blacklist.\n\n# declare a set, bound to table \"filter\", in family \"ip\".\n# Timeout and size are mandatory because we will add elements from packet path.\n# Entries will timeout after one minute, after which they might be\n# re-added if limit condition persists.\nnft add set ip filter blackhole \\\n\"{ type ipv4addr; flags dynamic; timeout 1m; size 65536; }\"\n\n# declare a set to store the limit per saddr.\n# This must be separate from blackhole since the timeout is different\nnft add set ip filter flood \\\n\"{ type ipv4addr; flags dynamic; timeout 10s; size 128000; }\"\n\n# whitelist internal interface.\nnft add rule ip filter input meta iifname \"internal\" accept\n\n# drop packets coming from blacklisted ip addresses.\nnft add rule ip filter input ip saddr @blackhole counter drop\n\n# add source ip addresses to the blacklist if more than 10 tcp connection\n# requests occurred per second and ip address.\nnft add rule ip filter input tcp flags syn tcp dport ssh \\\nadd @flood { ip saddr limit rate over 10/second } \\\nadd @blackhole { ip saddr } \\\ndrop\n\n# inspect state of the sets.\nnft list set ip filter flood\nnft list set ip filter blackhole\n\n# manually add two addresses to the blackhole.\nnft add element filter blackhole { 10.2.3.4, 10.23.1.42 }\n\n\nMAP STATEMENT\nThe map statement is used to lookup data based on some specific input key.\n\nexpression map { MAPELEMENTS }\n\nMAPELEMENTS := MAPELEMENT [, MAPELEMENTS]\nMAPELEMENT  := key : value\n\nThe key is a value returned by expression.\n\nUsing the map statement.\n\n# select DNAT target based on TCP dport:\n# connections to port 80 are redirected to 192.168.1.100,\n# connections to port 8888 are redirected to 192.168.1.101\nnft add rule ip nat prerouting dnat tcp dport map { 80 : 192.168.1.100, 8888 : 192.168.1.101 }\n\n# source address based SNAT:\n# packets from net 192.168.1.0/24 will appear as originating from 10.0.0.1,\n# packets from net 192.168.2.0/24 will appear as originating from 10.0.0.2\nnft add rule ip nat postrouting snat to ip saddr map { 192.168.1.0/24 : 10.0.0.1, 192.168.2.0/24 : 10.0.0.2 }\n\n\nVMAP STATEMENT\nThe verdict map (vmap) statement works analogous to the map statement, but contains verdicts\nas values.\n\nexpression vmap { VMAPELEMENTS }\n\nVMAPELEMENTS := VMAPELEMENT [, VMAPELEMENTS]\nVMAPELEMENT  := key : verdict\n\nUsing the vmap statement.\n\n# jump to different chains depending on layer 4 protocol type:\nnft add rule ip filter input ip protocol vmap { tcp : jump tcp-chain, udp : jump udp-chain , icmp : jump icmp-chain }\n\n"
                }
            ]
        },
        "ADDITIONAL COMMANDS": {
            "content": "These are some additional commands included in nft.\n\nMONITOR\nThe monitor command allows you to listen to Netlink events produced by the nftables\nsubsystem. These are either related to creation and deletion of objects or to packets for\nwhich meta nftrace was enabled. When they occur, nft will print to stdout the monitored\nevents in either JSON or native nft format.\n\nmonitor [new | destroy] MONITOROBJECT\nmonitor trace\n\nMONITOROBJECT := tables | chains | sets | rules | elements | ruleset\n\nTo filter events related to a concrete object, use one of the keywords in MONITOROBJECT.\n\nTo filter events related to a concrete action, use keyword new or destroy.\n\nThe second form of invocation takes no further options and exclusively prints events\ngenerated for packets with nftrace enabled.\n\nHit ^C to finish the monitor operation.\n\nListen to all events, report in native nft format.\n\n% nft monitor\n\nListen to deleted rules, report in JSON format.\n\n% nft -j monitor destroy rules\n\nListen to both new and destroyed chains, in native nft format.\n\n% nft monitor chains\n",
            "subsections": [
                {
                    "name": "Listen to ruleset events such as table, chain, rule, set, counters and quotas, in native nft",
                    "content": "format.\n\n% nft monitor ruleset\n\nTrace incoming packets from host 10.0.0.1.\n\n% nft add rule filter input ip saddr 10.0.0.1 meta nftrace set 1\n% nft monitor trace\n\n"
                }
            ]
        },
        "ERROR REPORTING": {
            "content": "When an error is detected, nft shows the line(s) containing the error, the position of the\nerroneous parts in the input stream and marks up the erroneous parts using carets (^). If the\nerror results from the combination of two expressions or statements, the part imposing the\nconstraints which are violated is marked using tildes (~).\n\nFor errors returned by the kernel, nft cannot detect which parts of the input caused the\nerror and the entire command is marked.\n\nError caused by single incorrect expression.\n\n<cmdline>:1:19-22: Error: Interface does not exist\nfilter output oif eth0\n^^^^\n\nError caused by invalid combination of two expressions.\n\n<cmdline>:1:28-36: Error: Right hand side of relational expression (==) must be constant\nfilter output tcp dport == tcp dport\n~~ ^^^^^^^^^\n\nError returned by the kernel.\n\n<cmdline>:0:0-23: Error: Could not process rule: Operation not permitted\nfilter output oif wlan0\n^^^^^^^^^^^^^^^^^^^^^^^\n\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "On success, nft exits with a status of 0. Unspecified errors cause it to exit with a status\nof 1, memory allocation errors with a status of 2, unable to open Netlink socket with 3.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "libnftables(3), libnftables-json(5), iptables(8), ip6tables(8), arptables(8), ebtables(8), ip(8), tc(8)\n\nThere is an official wiki at: https://wiki.nftables.org\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "nftables was written by Patrick McHardy and Pablo Neira Ayuso, among many other contributors\nfrom the Netfilter community.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2008-2014 Patrick McHardy <kaber@trash.net> Copyright © 2013-2018 Pablo Neira\nAyuso <pablo@netfilter.org>\n\nnftables is free software; you can redistribute it and/or modify it under the terms of the\nGNU General Public License version 2 as published by the Free Software Foundation.\n\nThis documentation is licensed under the terms of the Creative Commons Attribution-ShareAlike\n4.0 license, CC BY-SA 4.0 http://creativecommons.org/licenses/by-sa/4.0/.\n\n\n\n02/24/2026                                       NFT(8)",
            "subsections": []
        }
    },
    "summary": "nft - Administration tool of the nftables framework for packet filtering and classification",
    "flags": [
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Show help message and all options."
        },
        {
            "flag": "-v",
            "long": "--version",
            "arg": null,
            "description": "Show version."
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": "Show long version information, including compile-time configuration."
        },
        {
            "flag": "-f",
            "long": "--file",
            "arg": null,
            "description": "Read input from filename. If filename is -, read from stdin."
        },
        {
            "flag": "-D",
            "long": "--define",
            "arg": null,
            "description": "Define a variable. You can only combine this option with -f."
        },
        {
            "flag": "-i",
            "long": "--interactive",
            "arg": null,
            "description": "Read input from an interactive readline CLI. You can use quit to exit, or use the EOF marker, normally this is CTRL-D."
        },
        {
            "flag": "-I",
            "long": "--includepath",
            "arg": null,
            "description": "Add the directory directory to the list of directories to be searched for included files. This option may be specified multiple times."
        },
        {
            "flag": "-c",
            "long": "--check",
            "arg": null,
            "description": "Check commands validity without actually applying the changes."
        },
        {
            "flag": "-o",
            "long": "--optimize",
            "arg": null,
            "description": "Optimize your ruleset. You can combine this option with -c to inspect the proposed optimizations."
        },
        {
            "flag": "-a",
            "long": "--handle",
            "arg": null,
            "description": "Show object handles in output."
        },
        {
            "flag": "-s",
            "long": "--stateless",
            "arg": null,
            "description": "Omit stateful information of rules and stateful objects."
        },
        {
            "flag": "-t",
            "long": "--terse",
            "arg": null,
            "description": "Omit contents of sets from output."
        },
        {
            "flag": "-S",
            "long": "--service",
            "arg": null,
            "description": "Translate ports to service names as defined by /etc/services."
        },
        {
            "flag": "-N",
            "long": "--reversedns",
            "arg": null,
            "description": "Translate IP address to names via reverse DNS lookup. This may slow down your listing since it generates network traffic."
        },
        {
            "flag": "-u",
            "long": "--guid",
            "arg": null,
            "description": "Translate numeric UID/GID to names as defined by /etc/passwd and /etc/group."
        },
        {
            "flag": "-n",
            "long": "--numeric",
            "arg": null,
            "description": "Print fully numerical output."
        },
        {
            "flag": "-y",
            "long": "--numeric-priority",
            "arg": null,
            "description": "Display base chain priority numerically."
        },
        {
            "flag": "-p",
            "long": "--numeric-protocol",
            "arg": null,
            "description": "Display layer 4 protocol numerically."
        },
        {
            "flag": "-T",
            "long": "--numeric-time",
            "arg": null,
            "description": "Show time, day and hour values in numeric format."
        },
        {
            "flag": "-e",
            "long": "--echo",
            "arg": null,
            "description": "When inserting items into the ruleset using add, insert or replace commands, print notifications just like nft monitor."
        },
        {
            "flag": "-j",
            "long": "--json",
            "arg": null,
            "description": "Format output in JSON. See libnftables-json(5) for a schema description."
        },
        {
            "flag": "-d",
            "long": "--debug",
            "arg": null,
            "description": "Enable debugging output. The debug level can be any of scanner, parser, eval, netlink, mnl, proto-ctx, segtree, all. You can combine more than one by separating by the , symbol, for example -d eval,mnl."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "libnftables",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/libnftables/3/json"
        },
        {
            "name": "libnftables-json",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/libnftables-json/5/json"
        },
        {
            "name": "iptables",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/iptables/8/json"
        },
        {
            "name": "ip6tables",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ip6tables/8/json"
        },
        {
            "name": "arptables",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/arptables/8/json"
        },
        {
            "name": "ebtables",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ebtables/8/json"
        },
        {
            "name": "ip",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ip/8/json"
        },
        {
            "name": "tc",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
        }
    ]
}