Blame SOURCES/nft.8

ad45ff
'\" t -*- coding: us-ascii -*-
ad45ff
.if \n(.g .ds T< \\FC
ad45ff
.if \n(.g .ds T> \\F[\n[.fam]]
ad45ff
.de URL
ad45ff
\\$2 \(la\\$1\(ra\\$3
ad45ff
..
ad45ff
.if \n(.g .mso www.tmac
ad45ff
.TH nft 8 "4 April 2019" "" ""
ad45ff
.SH NAME
ad45ff
nft \- Administration tool for packet filtering and classification 
ad45ff
.SH SYNOPSIS
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBnft\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
[\fB-n\fR | \fB--numeric\fR] [\fB-N\fR | \fB--reversedns\fR] [\fB-s\fR | \fB--stateless\fR] [\fB-c\fR | \fB--check\fR] [\fB-a\fR | \fB--handle\fR] [\fB-e\fR | \fB--echo\fR] [
ad45ff
{\fB-I\fR | \fB--includepath\fR}
ad45ff
\fIdirectory\fR
ad45ff
] [
ad45ff
{\fB-f\fR | \fB--file\fR}
ad45ff
\fIfilename\fR
ad45ff
| 
ad45ff
{\fB-i\fR | \fB--interactive\fR}
ad45ff
| 
ad45ff
\fIcmd\fR
ad45ff
\&...]
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBnft\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
[\fB-h\fR | \fB--help\fR] [\fB-v\fR | \fB--version\fR]
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.SH DESCRIPTION
ad45ff
nft is used to set up, maintain and inspect packet
ad45ff
filtering and classification rules in the Linux kernel.
ad45ff
.SH OPTIONS
ad45ff
For a full summary of options, run \fBnft --help\fR.
ad45ff
.TP 
ad45ff
\*(T<\fB\-h, \-\-help\fR\*(T>
ad45ff
Show help message and all options.
ad45ff
.TP 
ad45ff
\*(T<\fB\-v, \-\-version\fR\*(T>
ad45ff
Show version.
ad45ff
.TP 
ad45ff
\*(T<\fB\-n, \-\-numeric\fR\*(T>
ad45ff
Show data numerically. When used once (the default behaviour), skip
ad45ff
lookup of addresses to symbolic names. Use twice to also show Internet
ad45ff
services (port numbers) numerically. Use three times to also show
ad45ff
protocols and UIDs/GIDs numerically.
ad45ff
.TP 
ad45ff
\*(T<\fB\-s, \-\-stateless\fR\*(T>
ad45ff
Omit stateful information of rules and stateful objects.
ad45ff
.TP 
ad45ff
\*(T<\fB\-c, \-\-check\fR\*(T>
ad45ff
Check commands validity without actually applying the changes.
ad45ff
.TP 
ad45ff
\*(T<\fB\-N, \-\-reversedns\fR\*(T>
ad45ff
Translate IP addresses to names. Usually requires network traffic for DNS lookup.
ad45ff
.TP 
ad45ff
\*(T<\fB\-a, \-\-handle\fR\*(T>
ad45ff
Show rule handles in output.
ad45ff
.TP 
ad45ff
\*(T<\fB\-e, \-\-echo\fR\*(T>
ad45ff
When inserting items into the ruleset using \fBadd\fR,
ad45ff
\fBinsert\fR or \fBreplace\fR commands,
ad45ff
print notifications just like \fBnft monitor\fR.
ad45ff
.TP 
ad45ff
\*(T<\fB\-I, \-\-includepath \fR\*(T>\fIdirectory\fR
ad45ff
Add the directory \fIdirectory\fR to the list of directories to be searched for included files. This option may be specified multiple times.
ad45ff
.TP 
ad45ff
\*(T<\fB\-f, \-\-file \fR\*(T>\fIfilename\fR
ad45ff
Read input from \fIfilename\fR.
ad45ff
.TP 
ad45ff
\*(T<\fB\-i, \-\-interactive\fR\*(T>
ad45ff
Read input from an interactive readline CLI.
ad45ff
.SH "INPUT FILE FORMAT"
ad45ff
.SS "LEXICAL CONVENTIONS"
ad45ff
Input is parsed line-wise. When the last character of a line, just before
ad45ff
the newline character, is a non-quoted backslash (\*(T<\e\*(T>),
ad45ff
the next line is treated as a continuation. Multiple commands on the
ad45ff
same line can be separated using a semicolon (\*(T<;\*(T>).
ad45ff
.PP
ad45ff
A hash sign (\*(T<#\*(T>) begins a comment. All following characters
ad45ff
on the same line are ignored.
ad45ff
.PP
ad45ff
Identifiers begin with an alphabetic character (\*(T<a\-z,A\-Z\*(T>),
ad45ff
followed zero or more alphanumeric characters (\*(T<a\-z,A\-Z,0\-9\*(T>)
ad45ff
and the characters slash (\*(T</\*(T>), backslash (\*(T<\e\*(T>),
ad45ff
underscore (\*(T<_\*(T>) and dot (\*(T<.\*(T>). Identifiers
ad45ff
using different characters or clashing with a keyword need to be enclosed in
ad45ff
double quotes (\*(T<"\*(T>).
ad45ff
.PP
ad45ff
.SS "INCLUDE FILES"
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBinclude\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
\fIfilename\fR
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Other files can be included by using the \fBinclude\fR statement.
ad45ff
The directories to be searched for include files can be specified using
ad45ff
the \*(T<\fB\-I/\-\-includepath\fR\*(T> option. You can override this behaviour
ad45ff
either by prepending ./ to your path to force inclusion of files located in the
ad45ff
current working directory (ie. relative path) or / for file location expressed
ad45ff
as an absolute path.
ad45ff
.PP
ad45ff
If -I/--includepath is not specified, then nft relies on the default directory
ad45ff
that is specified at compile time. You can retrieve this default directory via
ad45ff
-h/--help option.
ad45ff
.PP
ad45ff
Include statements support the usual shell wildcard symbols
ad45ff
(\*(T<*,?,[]\*(T>). Having no matches for an include statement is not
ad45ff
an error, if wildcard symbols are used in the include statement. This allows having
ad45ff
potentially empty include directories for statements like
ad45ff
\*(T<include "/etc/firewall/rules/*"\*(T>. The wildcard matches are
ad45ff
loaded in alphabetical order. Files beginning with dot (\*(T<.\*(T>) are
ad45ff
not matched by include statements.
ad45ff
.SS "SYMBOLIC VARIABLES"
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBdefine\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
variable \fIexpr\fR
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fB$variable\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Symbolic variables can be defined using the \fBdefine\fR statement.
ad45ff
Variable references are expressions and can be used initialize other variables.
ad45ff
The scope of a definition is the current block and all blocks contained within.
ad45ff
ad45ff
\fBUsing symbolic variables\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
define int_if1 = eth0
ad45ff
define int_if2 = eth1
ad45ff
define int_ifs = { $int_if1, $int_if2 }
ad45ff
ad45ff
filter input iif $int_ifs accept
ad45ff
					\*(T>
ad45ff
.fi
ad45ff
.SH "ADDRESS FAMILIES"
ad45ff
Address families determine the type of packets which are processed. For each address
ad45ff
family the kernel contains so called hooks at specific stages of the packet processing
ad45ff
paths, which invoke nftables if rules for these hooks exist.
ad45ff
.PP
ad45ff
.TP 
ad45ff
\*(T<\fBip\fR\*(T>
ad45ff
IPv4 address family.
ad45ff
.TP 
ad45ff
\*(T<\fBip6\fR\*(T>
ad45ff
IPv6 address family.
ad45ff
.TP 
ad45ff
\*(T<\fBinet\fR\*(T>
ad45ff
Internet (IPv4/IPv6) address family.
ad45ff
.TP 
ad45ff
\*(T<\fBarp\fR\*(T>
ad45ff
ARP address family, handling IPv4 ARP packets.
ad45ff
.TP 
ad45ff
\*(T<\fBbridge\fR\*(T>
ad45ff
Bridge address family, handling packets which traverse a bridge device.
ad45ff
.TP 
ad45ff
\*(T<\fBnetdev\fR\*(T>
ad45ff
Netdev address family, handling packets from ingress.
ad45ff
.PP
ad45ff
All nftables objects exist in address family specific namespaces, therefore
ad45ff
all identifiers include an address family. If an identifier is specified without
ad45ff
an address family, the \*(T<ip\*(T> family is used by default.
ad45ff
.SS "IPV4/IPV6/INET ADDRESS FAMILIES"
ad45ff
The IPv4/IPv6/Inet address families handle IPv4, IPv6 or both types of packets. They
ad45ff
contain five hooks at different packet processing stages in the network stack.
ad45ff
.PP
ad45ff
\fBIPv4/IPv6/Inet address family hooks\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Hook
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
prerouting
ad45ff
T}	T{
ad45ff
All packets entering the system are processed by the prerouting hook. It is invoked
ad45ff
before the routing process and is used for early filtering or changing packet
ad45ff
attributes that affect routing.
ad45ff
T}
ad45ff
T{
ad45ff
input
ad45ff
T}	T{
ad45ff
Packets delivered to the local system are processed by the input hook.
ad45ff
T}
ad45ff
T{
ad45ff
forward
ad45ff
T}	T{
ad45ff
Packets forwarded to a different host are processed by the forward hook.
ad45ff
T}
ad45ff
T{
ad45ff
output
ad45ff
T}	T{
ad45ff
Packets sent by local processes are processed by the output hook.
ad45ff
T}
ad45ff
T{
ad45ff
postrouting
ad45ff
T}	T{
ad45ff
All packets leaving the system are processed by the postrouting hook.
ad45ff
T}
ad45ff
.TE
ad45ff
.SS "ARP ADDRESS FAMILY"
ad45ff
The ARP address family handles ARP packets received and sent by the system. It is commonly used
ad45ff
to mangle ARP packets for clustering.
ad45ff
.PP
ad45ff
\fBARP address family hooks\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Hook
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}
ad45ff
.T&
ad45ff
l | l
ad45ff
l | l.
ad45ff
T{
ad45ff
input
ad45ff
T}	T{
ad45ff
Packets delivered to the local system are processed by the input hook.
ad45ff
T}
ad45ff
T{
ad45ff
output
ad45ff
T}	T{
ad45ff
Packets send by the local system are processed by the output hook.
ad45ff
T}
ad45ff
.TE
ad45ff
.SS "BRIDGE ADDRESS FAMILY"
ad45ff
The bridge address family handles ethernet packets traversing bridge devices.
ad45ff
.PP
ad45ff
The list of supported hooks is identical to IPv4/IPv6/Inet address families above.
ad45ff
.SS "NETDEV ADDRESS FAMILY"
ad45ff
The Netdev address family handles packets from ingress.
ad45ff
.PP
ad45ff
\fBNetdev address family hooks\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Hook
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
ingress
ad45ff
T}	T{
ad45ff
All packets entering the system are processed by this hook. It is invoked
ad45ff
before layer 3 protocol handlers and it can be used for early filtering and
ad45ff
policing.
ad45ff
T}
ad45ff
.TE
ad45ff
.SH RULESET
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{list | flush} \fBruleset\fR [\fIfamily\fR]
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
The \fBruleset\fR keyword is used to identify the whole
ad45ff
set of tables, chains, etc. currently in place in kernel. The
ad45ff
following \fBruleset\fR commands exist:
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
Print the ruleset in human-readable format.
ad45ff
.TP 
ad45ff
\*(T<\fBflush\fR\*(T>
ad45ff
Clear the whole ruleset. Note that unlike iptables, this
ad45ff
will remove all tables and whatever they contain,
ad45ff
effectively leading to an empty ruleset - no packet
ad45ff
filtering will happen anymore, so the kernel accepts any
ad45ff
valid packet it receives.
ad45ff
.PP
ad45ff
It is possible to limit \fBlist\fR and
ad45ff
\fBflush\fR to a specific address family only. For a
ad45ff
list of valid family names, see \*(T<ADDRESS FAMILIES\*(T> above.
ad45ff
.PP
ad45ff
By design, \fBlist ruleset\fR command output may be used as
ad45ff
input to \fBnft -f\fR. Effectively, this is the nft-equivalent
ad45ff
of \fBiptables-save\fR and \fBiptables-restore\fR.
ad45ff
.SH TABLES
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add | delete | list | flush} \fBtable\fR [\fIfamily\fR] {\fItable\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Tables are containers for chains, sets and stateful objects. They are identified by their address family
ad45ff
and their name. The address family must be one of
ad45ff
\*(T<ip\*(T>, \*(T<ip6\*(T>, \*(T<inet\*(T>, \*(T<arp\*(T>, \*(T<bridge\*(T>, \*(T<netdev\*(T>.
ad45ff
The \*(T<inet\*(T> address family is a dummy family which is used to create
ad45ff
hybrid IPv4/IPv6 tables. The \*(T<meta\*(T> expression \*(T<nfproto\*(T>
ad45ff
keyword can be used to test which family (ipv4 or ipv6) context the packet is being processed in.
ad45ff
When no address family is specified, \*(T<ip\*(T> is used by default.
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new table for the given family with the given name.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified table.
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
List all chains and rules of the specified table.
ad45ff
.TP 
ad45ff
\*(T<\fBflush\fR\*(T>
ad45ff
Flush all chains and rules of the specified table.
ad45ff
.SH CHAINS
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add | create} \fBchain\fR [\fIfamily\fR] \fItable\fR \fIchain\fR [
ad45ff
{
ad45ff
{\fItype\fR}
ad45ff
{\fIhook\fR}
ad45ff
[\fIdevice\fR]
ad45ff
{\fIpriority\fR ;}
ad45ff
[\fIpolicy\fR ;]
ad45ff
}
ad45ff
]
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{delete | list | flush} \fBchain\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{rename} \fBchain\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {\fInewname\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Chains are containers for rules. They exist in two kinds,
ad45ff
base chains and regular chains. A base chain is an entry point for
ad45ff
packets from the networking stack, a regular chain may be used
ad45ff
as jump target and is used for better rule organization.
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new chain in the specified table. When a hook and priority
ad45ff
value are specified, the chain is created as a base chain and hooked
ad45ff
up to the networking stack.
ad45ff
.TP 
ad45ff
\*(T<\fBcreate\fR\*(T>
ad45ff
Similar to the \fBadd\fR command, but returns an error if the
ad45ff
chain already exists.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified chain. The chain must not contain any rules or be
ad45ff
used as jump target.
ad45ff
.TP 
ad45ff
\*(T<\fBrename\fR\*(T>
ad45ff
Rename the specified chain.
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
List all rules of the specified chain.
ad45ff
.TP 
ad45ff
\*(T<\fBflush\fR\*(T>
ad45ff
Flush all rules of the specified chain.
ad45ff
.PP
ad45ff
For base chains, \fBtype\fR, \fBhook\fR and \fBpriority\fR parameters are mandatory.
ad45ff
.PP
ad45ff
\fBSupported chain types\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Type
ad45ff
T}	T{
ad45ff
Families
ad45ff
T}	T{
ad45ff
Hooks
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l
ad45ff
l | l | l | l
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
filter
ad45ff
T}	T{
ad45ff
all
ad45ff
T}	T{
ad45ff
all
ad45ff
T}	T{
ad45ff
Standard chain type to use in doubt.
ad45ff
T}
ad45ff
T{
ad45ff
nat
ad45ff
T}	T{
ad45ff
ip, ip6
ad45ff
T}	T{
ad45ff
prerouting, input, output, postrouting
ad45ff
T}	T{
ad45ff
Chains of this type perform Native Address Translation based on conntrack entries. Only the first packet of a connection actually traverses this chain - its rules usually define details of the created conntrack entry (NAT statements for instance).
ad45ff
T}
ad45ff
T{
ad45ff
route
ad45ff
T}	T{
ad45ff
ip, ip6
ad45ff
T}	T{
ad45ff
output
ad45ff
T}	T{
ad45ff
If a packet has traversed a chain of this
ad45ff
type and is about to be accepted, a new route
ad45ff
lookup is performed if relevant parts of the IP
ad45ff
header have changed. This allows to e.g.
ad45ff
implement policy routing selectors in
ad45ff
nftables.
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
Apart from the special cases illustrated above (e.g. \*(T<nat\*(T> type not supporting \*(T<forward\*(T> hook or \*(T<route\*(T> type only supporting \*(T<output\*(T> hook), there are two further quirks worth noticing:
ad45ff
.TP 0.2i
ad45ff
\(bu
ad45ff
\*(T<netdev\*(T> family supports merely a single
ad45ff
combination, namely \*(T<filter\*(T> type and
ad45ff
\*(T<ingress\*(T> hook. Base chains in this family also require the \*(T<device\*(T> parameter to be present since they exist per incoming interface only.
ad45ff
.TP 0.2i
ad45ff
\(bu
ad45ff
\*(T<arp\*(T> family supports only
ad45ff
\*(T<input\*(T> and \*(T<output\*(T>
ad45ff
hooks, both in chains of type
ad45ff
\*(T<filter\*(T>.
ad45ff
.PP
ad45ff
The \*(T<priority\*(T> parameter accepts a signed integer value which specifies the order in which chains with same \*(T<hook\*(T> value are traversed. The ordering is ascending, i.e. lower priority values have precedence over higher ones.
ad45ff
.PP
ad45ff
Base chains also allow to set the chain's \*(T<policy\*(T>, i.e. what happens to packets not explicitly accepted or refused in contained rules. Supported policy values are \*(T<accept\*(T> (which is the default) or \*(T<drop\*(T>.
ad45ff
.SH RULES
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
[add | insert] \fBrule\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} [
ad45ff
{handle | position}
ad45ff
\fIhandle\fR
ad45ff
] {\fIstatement\fR}\&...
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{replace} \fBrule\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {handle \fIhandle\fR} {\fIstatement\fR}\&...
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{delete} \fBrule\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {handle \fIhandle\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Rules are constructed from two kinds of components according to a set
ad45ff
of grammatical rules: expressions and statements.
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new rule described by the list of statements. The rule is appended to the
ad45ff
given chain unless a \*(T<handle\*(T> is specified, in which case the
ad45ff
rule is appended to the rule given by the \fIhandle\fR.
ad45ff
The alternative name \*(T<position\*(T> is deprecated and should not be
ad45ff
used anymore.
ad45ff
.TP 
ad45ff
\*(T<\fBinsert\fR\*(T>
ad45ff
Similar to the \fBadd\fR command, but the rule is prepended to the
ad45ff
beginning of the chain or before the rule with the given
ad45ff
\fIhandle\fR.
ad45ff
.TP 
ad45ff
\*(T<\fBreplace\fR\*(T>
ad45ff
Similar to the \fBadd\fR command, but the rule replaces the specified rule.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified rule.
ad45ff
.SH SETS
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add} \fBset\fR [\fIfamily\fR] {\fItable\fR} {\fIset\fR}
ad45ff
{
ad45ff
{\fItype\fR} [\fIflags\fR] [\fItimeout\fR] [\fIgc-interval\fR] [\fIelements\fR] [\fIsize\fR] [\fIpolicy\fR]
ad45ff
}
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{delete | list | flush} \fBset\fR [\fIfamily\fR] {\fItable\fR} {\fIset\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add | delete} \fBelement\fR [\fIfamily\fR] {\fItable\fR} {\fIset\fR}
ad45ff
{
ad45ff
{\fIelements\fR}
ad45ff
}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Sets are elements containers of an user-defined data type, they are uniquely identified by an user-defined name and attached to tables.
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new set in the specified table.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified set.
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
Display the elements in the specified set.
ad45ff
.TP 
ad45ff
\*(T<\fBflush\fR\*(T>
ad45ff
Remove all elements from the specified set.
ad45ff
.TP 
ad45ff
\*(T<\fBadd element\fR\*(T>
ad45ff
Comma-separated list of elements to add into the specified set.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete element\fR\*(T>
ad45ff
Comma-separated list of elements to delete from the specified set.
ad45ff
.PP
ad45ff
\fBSet specifications\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l.
ad45ff
T{
ad45ff
type
ad45ff
T}	T{
ad45ff
data type of set elements
ad45ff
T}	T{
ad45ff
string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark
ad45ff
T}
ad45ff
T{
ad45ff
flags
ad45ff
T}	T{
ad45ff
set flags
ad45ff
T}	T{
ad45ff
string: constant, interval, timeout
ad45ff
T}
ad45ff
T{
ad45ff
timeout
ad45ff
T}	T{
ad45ff
time an element stays in the set
ad45ff
T}	T{
ad45ff
string, decimal followed by unit. Units are: d, h, m, s
ad45ff
T}
ad45ff
T{
ad45ff
gc-interval
ad45ff
T}	T{
ad45ff
garbage collection interval, only available when timeout or flag timeout are active
ad45ff
T}	T{
ad45ff
string, decimal followed by unit. Units are: d, h, m, s
ad45ff
T}
ad45ff
T{
ad45ff
elements
ad45ff
T}	T{
ad45ff
elements contained by the set
ad45ff
T}	T{
ad45ff
set data type
ad45ff
T}
ad45ff
T{
ad45ff
size
ad45ff
T}	T{
ad45ff
maximun number of elements in the set
ad45ff
T}	T{
ad45ff
unsigned integer (64 bit)
ad45ff
T}
ad45ff
T{
ad45ff
policy
ad45ff
T}	T{
ad45ff
set policy
ad45ff
T}	T{
ad45ff
string: performance [default], memory
ad45ff
T}
ad45ff
.TE
ad45ff
.SH MAPS
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add} \fBmap\fR [\fIfamily\fR] {\fItable\fR} {\fImap\fR}
ad45ff
{
ad45ff
{\fItype\fR} [\fIflags\fR] [\fIelements\fR] [\fIsize\fR] [\fIpolicy\fR]
ad45ff
}
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{delete | list | flush} \fBmap\fR [\fIfamily\fR] {\fItable\fR} {\fImap\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add | delete} \fBelement\fR [\fIfamily\fR] {\fItable\fR} {\fImap\fR}
ad45ff
{
ad45ff
{\fIelements\fR}
ad45ff
}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Maps store data based on some specific key used as input, they are uniquely identified by an user-defined name and attached to tables.
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new map in the specified table.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified map.
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
Display the elements in the specified map.
ad45ff
.TP 
ad45ff
\*(T<\fBflush\fR\*(T>
ad45ff
Remove all elements from the specified map.
ad45ff
.TP 
ad45ff
\*(T<\fBadd element\fR\*(T>
ad45ff
Comma-separated list of elements to add into the specified map.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete element\fR\*(T>
ad45ff
Comma-separated list of element keys to delete from the specified map.
ad45ff
.PP
ad45ff
\fBMap specifications\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l.
ad45ff
T{
ad45ff
type
ad45ff
T}	T{
ad45ff
data type of map elements
ad45ff
T}	T{
ad45ff
string ':' string: ipv4_addr, ipv6_addr, ether_addr, inet_proto, inet_service, mark, counter, quota. Counter and quota can't be used as keys
ad45ff
T}
ad45ff
T{
ad45ff
flags
ad45ff
T}	T{
ad45ff
map flags
ad45ff
T}	T{
ad45ff
string: constant, interval
ad45ff
T}
ad45ff
T{
ad45ff
elements
ad45ff
T}	T{
ad45ff
elements contained by the map
ad45ff
T}	T{
ad45ff
map data type
ad45ff
T}
ad45ff
T{
ad45ff
size
ad45ff
T}	T{
ad45ff
maximun number of elements in the map
ad45ff
T}	T{
ad45ff
unsigned integer (64 bit)
ad45ff
T}
ad45ff
T{
ad45ff
policy
ad45ff
T}	T{
ad45ff
map policy
ad45ff
T}	T{
ad45ff
string: performance [default], memory
ad45ff
T}
ad45ff
.TE
ad45ff
.SH "STATEFUL OBJECTS"
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
{add | delete | list | reset} \fBtype\fR [\fIfamily\fR] {\fItable\fR} {\fIobject\fR}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Stateful objects are attached to tables and are identified by an unique name. They group stateful information from rules, to reference them in rules the keywords "type name" are used e.g. "counter name".
ad45ff
.TP 
ad45ff
\*(T<\fBadd\fR\*(T>
ad45ff
Add a new stateful object in the specified table.
ad45ff
.TP 
ad45ff
\*(T<\fBdelete\fR\*(T>
ad45ff
Delete the specified object.
ad45ff
.TP 
ad45ff
\*(T<\fBlist\fR\*(T>
ad45ff
Display stateful information the object holds.
ad45ff
.TP 
ad45ff
\*(T<\fBreset\fR\*(T>
ad45ff
List-and-reset stateful object.
ad45ff
.SS CT
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBct\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
{helper} {type} {\fItype\fR} {protocol} {\fIprotocol\fR} [l3proto] [\fIfamily\fR]
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
Ct helper is used to define connection tracking helpers that can then be used in combination with the \*(T<"ct helper set"\*(T> statement.
ad45ff
type and protocol are mandatory, l3proto is derived from the table family by default, i.e. in the inet table the kernel will
ad45ff
try to load both the ipv4 and ipv6 helper backends, if they are supported by the kernel.
ad45ff
.PP
ad45ff
\fBconntrack helper specifications\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l
ad45ff
l | l | l
ad45ff
l | l | l.
ad45ff
T{
ad45ff
type
ad45ff
T}	T{
ad45ff
name of helper type
ad45ff
T}	T{
ad45ff
quoted string (e.g. "ftp")
ad45ff
T}
ad45ff
T{
ad45ff
protocol
ad45ff
T}	T{
ad45ff
layer 4 protocol of the helper
ad45ff
T}	T{
ad45ff
string (e.g. tcp)
ad45ff
T}
ad45ff
T{
ad45ff
l3proto
ad45ff
T}	T{
ad45ff
layer 3 protocol of the helper
ad45ff
T}	T{
ad45ff
address family (e.g. ip)
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBdefining and assigning ftp helper\fR
ad45ff
.PP
ad45ff
Unlike iptables, helper assignment needs to be performed after the conntrack lookup has completed, for example
ad45ff
with the default 0 hook priority.
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
table inet myhelpers {
ad45ff
  ct helper ftp\-standard {
ad45ff
     type "ftp" protocol tcp
ad45ff
  }
ad45ff
  chain prerouting {
ad45ff
      type filter hook prerouting priority 0;
ad45ff
      tcp dport 21 ct helper set "ftp\-standard"
ad45ff
  }
ad45ff
}
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS COUNTER
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBcounter\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
[packets bytes]
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
\fBCounter specifications\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l
ad45ff
l | l | l.
ad45ff
T{
ad45ff
packets
ad45ff
T}	T{
ad45ff
initial count of packets
ad45ff
T}	T{
ad45ff
unsigned integer (64 bit)
ad45ff
T}
ad45ff
T{
ad45ff
bytes
ad45ff
T}	T{
ad45ff
initial count of bytes
ad45ff
T}	T{
ad45ff
unsigned integer (64 bit)
ad45ff
T}
ad45ff
.TE
ad45ff
.SS QUOTA
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBquota\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
[over | until] [used]
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
\fBQuota specifications\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l
ad45ff
l | l | l.
ad45ff
T{
ad45ff
quota
ad45ff
T}	T{
ad45ff
quota limit, used as the quota name
ad45ff
T}	T{
ad45ff
Two arguments, unsigned interger (64 bit) and string: bytes, kbytes, mbytes. "over" and "until" go before these arguments
ad45ff
T}
ad45ff
T{
ad45ff
used
ad45ff
T}	T{
ad45ff
initial value of used quota
ad45ff
T}	T{
ad45ff
Two arguments, unsigned interger (64 bit) and string: bytes, kbytes, mbytes
ad45ff
T}
ad45ff
.TE
ad45ff
.SH EXPRESSIONS
ad45ff
Expressions represent values, either constants like network addresses, port numbers etc. or data
ad45ff
gathered from the packet during ruleset evaluation. Expressions can be combined using binary,
ad45ff
logical, relational and other types of expressions to form complex or relational (match) expressions.
ad45ff
They are also used as arguments to certain types of operations, like NAT, packet marking etc.
ad45ff
.PP
ad45ff
Each expression has a data type, which determines the size, parsing and representation of
ad45ff
symbolic values and type compatibility with other expressions.
ad45ff
.SS "DESCRIBE COMMAND"
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBdescribe\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
{\fIexpression\fR}
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
The \fBdescribe\fR command shows information about the type of an expression and
ad45ff
its data type.
ad45ff
.PP
ad45ff
\fBThe describe command\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
$ nft describe tcp flags
ad45ff
payload expression, datatype tcp_flag (TCP flag) (basetype bitmask, integer), 8 bits
ad45ff
ad45ff
pre\-defined symbolic constants:
ad45ff
fin                           	0x01
ad45ff
syn                           	0x02
ad45ff
rst                           	0x04
ad45ff
psh                           	0x08
ad45ff
ack                           	0x10
ad45ff
urg                           	0x20
ad45ff
ecn                           	0x40
ad45ff
cwr                           	0x80
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SH "DATA TYPES"
ad45ff
Data types determine the size, parsing and representation of symbolic values and type compatibility
ad45ff
of expressions. A number of global data types exist, in addition some expression types define further
ad45ff
data types specific to the expression type. Most data types have a fixed size, some however may have
ad45ff
a dynamic size, f.i. the string type.
ad45ff
.PP
ad45ff
Types may be derived from lower order types, f.i. the IPv4 address type is derived from the integer
ad45ff
type, meaning an IPv4 address can also be specified as an integer value.
ad45ff
.PP
ad45ff
In certain contexts (set and map definitions) it is necessary to explicitly specify a data type.
ad45ff
Each type has a name which is used for this.
ad45ff
.SS "INTEGER TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Integer
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}	T{
ad45ff
variable
ad45ff
T}	T{
ad45ff
-
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The integer type is used for numeric values. It may be specified as decimal, hexadecimal
ad45ff
or octal number. The integer type doesn't have a fixed size, its size is determined by the
ad45ff
expression for which it is used.
ad45ff
.SS "BITMASK TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Bitmask
ad45ff
T}	T{
ad45ff
bitmask
ad45ff
T}	T{
ad45ff
variable
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The bitmask type (\fBbitmask\fR) is used for bitmasks. 
ad45ff
.SS "STRING TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
String
ad45ff
T}	T{
ad45ff
string
ad45ff
T}	T{
ad45ff
variable
ad45ff
T}	T{
ad45ff
-
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The string type is used to for character strings. A string begins with an alphabetic character
ad45ff
(a-zA-Z) followed by zero or more alphanumeric characters or the characters \*(T</\*(T>,
ad45ff
\*(T<\-\*(T>, \*(T<_\*(T> and \*(T<.\*(T>. In addition anything enclosed
ad45ff
in double quotes (\*(T<"\*(T>) is recognized as a string.
ad45ff
.PP
ad45ff
\fBString specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# Interface name
ad45ff
filter input iifname eth0
ad45ff
ad45ff
# Weird interface name
ad45ff
filter input iifname "(eth0)"
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "LINK LAYER ADDRESS TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Link layer address
ad45ff
T}	T{
ad45ff
lladdr
ad45ff
T}	T{
ad45ff
variable
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The link layer address type is used for link layer addresses. Link layer addresses are specified
ad45ff
as a variable amount of groups of two hexadecimal digits separated using colons (\*(T<:\*(T>).
ad45ff
.PP
ad45ff
\fBLink layer address specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# Ethernet destination MAC address
ad45ff
filter input ether daddr 20:c9:d0:43:12:d9
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "IPV4 ADDRESS TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
IPv4 address
ad45ff
T}	T{
ad45ff
ipv4_addr
ad45ff
T}	T{
ad45ff
32 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The IPv4 address type is used for IPv4 addresses. Addresses are specified in either dotted decimal,
ad45ff
dotted hexadecimal, dotted octal, decimal, hexadecimal, octal notation or as a host name. A host name
ad45ff
will be resolved using the standard system resolver.
ad45ff
.PP
ad45ff
\fBIPv4 address specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# dotted decimal notation
ad45ff
filter output ip daddr 127.0.0.1
ad45ff
ad45ff
# host name
ad45ff
filter output ip daddr localhost
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "IPV6 ADDRESS TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
IPv6 address
ad45ff
T}	T{
ad45ff
ipv6_addr
ad45ff
T}	T{
ad45ff
128 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The IPv6 address type is used for IPv6 addresses. FIXME
ad45ff
.PP
ad45ff
\fBIPv6 address specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# abbreviated loopback address
ad45ff
filter output ip6 daddr ::1
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "BOOLEAN TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Boolean
ad45ff
T}	T{
ad45ff
boolean
ad45ff
T}	T{
ad45ff
1 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The boolean type is a syntactical helper type in user space.
ad45ff
It's use is in the right-hand side of a (typically implicit)
ad45ff
relational expression to change the expression on the left-hand
ad45ff
side into a boolean check (usually for existence).
ad45ff
.PP
ad45ff
The following keywords will automatically resolve into a boolean
ad45ff
type with given value:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l
ad45ff
l | l.
ad45ff
T{
ad45ff
exists
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
missing
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBBoolean specification\fR
ad45ff
.PP
ad45ff
The following expressions support a boolean comparison:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Expression
ad45ff
T}	T{
ad45ff
Behaviour
ad45ff
T}
ad45ff
.T&
ad45ff
l | l
ad45ff
l | l
ad45ff
l | l.
ad45ff
T{
ad45ff
fib
ad45ff
T}	T{
ad45ff
Check route existence.
ad45ff
T}
ad45ff
T{
ad45ff
exthdr
ad45ff
T}	T{
ad45ff
Check IPv6 extension header existence.
ad45ff
T}
ad45ff
T{
ad45ff
tcp option
ad45ff
T}	T{
ad45ff
Check TCP option header existence.
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# match if route exists
ad45ff
filter input fib daddr . iif oif exists
ad45ff
ad45ff
# match only non\-fragmented packets in IPv6 traffic
ad45ff
filter input exthdr frag missing
ad45ff
ad45ff
# match if TCP timestamp option is present
ad45ff
filter input tcp option timestamp exists
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "ICMP TYPE TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
ICMP Type
ad45ff
T}	T{
ad45ff
icmp_type
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The ICMP Type type is used to conveniently specify the ICMP header's type field.
ad45ff
.PP
ad45ff
The following keywords may be used when specifying the ICMP type:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
echo-reply
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
T{
ad45ff
destination-unreachable
ad45ff
T}	T{
ad45ff
3
ad45ff
T}
ad45ff
T{
ad45ff
source-quench
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
redirect
ad45ff
T}	T{
ad45ff
5
ad45ff
T}
ad45ff
T{
ad45ff
echo-request
ad45ff
T}	T{
ad45ff
8
ad45ff
T}
ad45ff
T{
ad45ff
router-advertisement
ad45ff
T}	T{
ad45ff
9
ad45ff
T}
ad45ff
T{
ad45ff
router-solicitation
ad45ff
T}	T{
ad45ff
10
ad45ff
T}
ad45ff
T{
ad45ff
time-exceeded
ad45ff
T}	T{
ad45ff
11
ad45ff
T}
ad45ff
T{
ad45ff
parameter-problem
ad45ff
T}	T{
ad45ff
12
ad45ff
T}
ad45ff
T{
ad45ff
timestamp-request
ad45ff
T}	T{
ad45ff
13
ad45ff
T}
ad45ff
T{
ad45ff
timestamp-reply
ad45ff
T}	T{
ad45ff
14
ad45ff
T}
ad45ff
T{
ad45ff
info-request
ad45ff
T}	T{
ad45ff
15
ad45ff
T}
ad45ff
T{
ad45ff
info-reply
ad45ff
T}	T{
ad45ff
16
ad45ff
T}
ad45ff
T{
ad45ff
address-mask-request
ad45ff
T}	T{
ad45ff
17
ad45ff
T}
ad45ff
T{
ad45ff
address-mask-reply
ad45ff
T}	T{
ad45ff
18
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBICMP Type specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# match ping packets
ad45ff
filter output icmp type { echo\-request, echo\-reply }
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "ICMP CODE TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
ICMP Code
ad45ff
T}	T{
ad45ff
icmp_code
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The ICMP Code type is used to conveniently specify the ICMP header's code field.
ad45ff
.PP
ad45ff
The following keywords may be used when specifying the ICMP code:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
net-unreachable
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
T{
ad45ff
host-unreachable
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
prot-unreachable
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
port-unreachable
ad45ff
T}	T{
ad45ff
3
ad45ff
T}
ad45ff
T{
ad45ff
net-prohibited
ad45ff
T}	T{
ad45ff
9
ad45ff
T}
ad45ff
T{
ad45ff
host-prohibited
ad45ff
T}	T{
ad45ff
10
ad45ff
T}
ad45ff
T{
ad45ff
admin-prohibited
ad45ff
T}	T{
ad45ff
13
ad45ff
T}
ad45ff
.TE
ad45ff
.SS "ICMPV6 TYPE TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
ICMPv6 Type
ad45ff
T}	T{
ad45ff
icmpv6_type
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The ICMPv6 Type type is used to conveniently specify the ICMPv6 header's type field.
ad45ff
.PP
ad45ff
The following keywords may be used when specifying the ICMPv6 type:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
destination-unreachable
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
packet-too-big
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
time-exceeded
ad45ff
T}	T{
ad45ff
3
ad45ff
T}
ad45ff
T{
ad45ff
parameter-problem
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
echo-request
ad45ff
T}	T{
ad45ff
128
ad45ff
T}
ad45ff
T{
ad45ff
echo-reply
ad45ff
T}	T{
ad45ff
129
ad45ff
T}
ad45ff
T{
ad45ff
mld-listener-query
ad45ff
T}	T{
ad45ff
130
ad45ff
T}
ad45ff
T{
ad45ff
mld-listener-report
ad45ff
T}	T{
ad45ff
131
ad45ff
T}
ad45ff
T{
ad45ff
mld-listener-done
ad45ff
T}	T{
ad45ff
132
ad45ff
T}
ad45ff
T{
ad45ff
mld-listener-reduction
ad45ff
T}	T{
ad45ff
132
ad45ff
T}
ad45ff
T{
ad45ff
nd-router-solicit
ad45ff
T}	T{
ad45ff
133
ad45ff
T}
ad45ff
T{
ad45ff
nd-router-advert
ad45ff
T}	T{
ad45ff
134
ad45ff
T}
ad45ff
T{
ad45ff
nd-neighbor-solicit
ad45ff
T}	T{
ad45ff
135
ad45ff
T}
ad45ff
T{
ad45ff
nd-neighbor-advert
ad45ff
T}	T{
ad45ff
136
ad45ff
T}
ad45ff
T{
ad45ff
nd-redirect
ad45ff
T}	T{
ad45ff
137
ad45ff
T}
ad45ff
T{
ad45ff
router-renumbering
ad45ff
T}	T{
ad45ff
138
ad45ff
T}
ad45ff
T{
ad45ff
ind-neighbor-solicit
ad45ff
T}	T{
ad45ff
141
ad45ff
T}
ad45ff
T{
ad45ff
ind-neighbor-advert
ad45ff
T}	T{
ad45ff
142
ad45ff
T}
ad45ff
T{
ad45ff
mld2-listener-report
ad45ff
T}	T{
ad45ff
143
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBICMPv6 Type specification\fR
ad45ff
.PP
ad45ff
.nf
ad45ff
\*(T<
ad45ff
# match ICMPv6 ping packets
ad45ff
filter output icmpv6 type { echo\-request, echo\-reply }
ad45ff
				\*(T>
ad45ff
.fi
ad45ff
.SS "ICMPV6 CODE TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
ICMPv6 Code
ad45ff
T}	T{
ad45ff
icmpv6_code
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The ICMPv6 Code type is used to conveniently specify the ICMPv6 header's code field.
ad45ff
.PP
ad45ff
The following keywords may be used when specifying the ICMPv6 code:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
no-route
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
T{
ad45ff
admin-prohibited
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
addr-unreachable
ad45ff
T}	T{
ad45ff
3
ad45ff
T}
ad45ff
T{
ad45ff
port-unreachable
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
policy-fail
ad45ff
T}	T{
ad45ff
5
ad45ff
T}
ad45ff
T{
ad45ff
reject-route
ad45ff
T}	T{
ad45ff
6
ad45ff
T}
ad45ff
.TE
ad45ff
.SS "ICMPVX CODE TYPE"
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
ICMPvX Code
ad45ff
T}	T{
ad45ff
icmpx_code
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
The ICMPvX Code type abstraction is a set of values which
ad45ff
overlap between ICMP and ICMPv6 Code types to be used from the
ad45ff
inet family.
ad45ff
.PP
ad45ff
The following keywords may be used when specifying the ICMPvX code:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
no-route
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
T{
ad45ff
port-unreachable
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
host-unreachable
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
admin-prohibited
ad45ff
T}	T{
ad45ff
3
ad45ff
T}
ad45ff
.TE
ad45ff
.SS "CONNTRACK TYPES"
ad45ff
This is an overview of types used in \fBct\fR
ad45ff
expression and statement:
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
Name
ad45ff
T}	T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Size
ad45ff
T}	T{
ad45ff
Base type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l | l.
ad45ff
T{
ad45ff
conntrack state
ad45ff
T}	T{
ad45ff
ct_state
ad45ff
T}	T{
ad45ff
4 byte
ad45ff
T}	T{
ad45ff
bitmask
ad45ff
T}
ad45ff
T{
ad45ff
conntrack direction
ad45ff
T}	T{
ad45ff
ct_dir
ad45ff
T}	T{
ad45ff
8 bit
ad45ff
T}	T{
ad45ff
integer
ad45ff
T}
ad45ff
T{
ad45ff
conntrack status
ad45ff
T}	T{
ad45ff
ct_status
ad45ff
T}	T{
ad45ff
4 byte
ad45ff
T}	T{
ad45ff
bitmask
ad45ff
T}
ad45ff
T{
ad45ff
conntrack event bits
ad45ff
T}	T{
ad45ff
ct_event
ad45ff
T}	T{
ad45ff
4 byte
ad45ff
T}	T{
ad45ff
bitmask
ad45ff
T}
ad45ff
T{
ad45ff
conntrack label
ad45ff
T}	T{
ad45ff
ct_label
ad45ff
T}	T{
ad45ff
128 bit
ad45ff
T}	T{
ad45ff
bitmask
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
For each of the types above, keywords are available for convenience:
ad45ff
ad45ff
\fBconntrack state (ct_state)\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
invalid
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
established
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
related
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
new
ad45ff
T}	T{
ad45ff
8
ad45ff
T}
ad45ff
T{
ad45ff
untracked
ad45ff
T}	T{
ad45ff
64
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBconntrack direction (ct_dir)\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l
ad45ff
l | l.
ad45ff
T{
ad45ff
original
ad45ff
T}	T{
ad45ff
0
ad45ff
T}
ad45ff
T{
ad45ff
reply
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBconntrack status (ct_status)\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
expected
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
seen-reply
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
assured
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
confirmed
ad45ff
T}	T{
ad45ff
8
ad45ff
T}
ad45ff
T{
ad45ff
snat
ad45ff
T}	T{
ad45ff
16
ad45ff
T}
ad45ff
T{
ad45ff
dnat
ad45ff
T}	T{
ad45ff
32
ad45ff
T}
ad45ff
T{
ad45ff
dying
ad45ff
T}	T{
ad45ff
512
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
\fBconntrack event bits (ct_event)\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Value
ad45ff
T}
ad45ff
.T&
ad45ff
l | l.
ad45ff
T{
ad45ff
new
ad45ff
T}	T{
ad45ff
1
ad45ff
T}
ad45ff
T{
ad45ff
related
ad45ff
T}	T{
ad45ff
2
ad45ff
T}
ad45ff
T{
ad45ff
destroy
ad45ff
T}	T{
ad45ff
4
ad45ff
T}
ad45ff
T{
ad45ff
reply
ad45ff
T}	T{
ad45ff
8
ad45ff
T}
ad45ff
T{
ad45ff
assured
ad45ff
T}	T{
ad45ff
16
ad45ff
T}
ad45ff
T{
ad45ff
protoinfo
ad45ff
T}	T{
ad45ff
32
ad45ff
T}
ad45ff
T{
ad45ff
helper
ad45ff
T}	T{
ad45ff
64
ad45ff
T}
ad45ff
T{
ad45ff
mark
ad45ff
T}	T{
ad45ff
128
ad45ff
T}
ad45ff
T{
ad45ff
seqadj
ad45ff
T}	T{
ad45ff
256
ad45ff
T}
ad45ff
T{
ad45ff
secmark
ad45ff
T}	T{
ad45ff
512
ad45ff
T}
ad45ff
T{
ad45ff
label
ad45ff
T}	T{
ad45ff
1024
ad45ff
T}
ad45ff
.TE
ad45ff
.PP
ad45ff
Possible keywords for conntrack label type
ad45ff
(\fBct_label\fR) are read at runtime from
ad45ff
\*(T</etc/connlabel.conf\*(T>.
ad45ff
.SH "PRIMARY EXPRESSIONS"
ad45ff
The lowest order expression is a primary expression, representing either a constant or a single
ad45ff
datum from a packet's payload, meta data or a stateful module. 
ad45ff
.SS "META EXPRESSIONS"
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
\fBmeta\fR \kx
ad45ff
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
ad45ff
'in \n(.iu+\nxu
ad45ff
{length | nfproto | l4proto | protocol | priority}
ad45ff
'in \n(.iu-\nxu
ad45ff
.ad b
ad45ff
'hy
ad45ff
'nh
ad45ff
.fi
ad45ff
.ad l
ad45ff
[meta] {mark | iif | iifname | iiftype | oif | oifname | oiftype | skuid | skgid | nftrace | rtclassid | ibriport | obriport | pkttype | cpu | iifgroup | oifgroup | cgroup | random}
ad45ff
.ad b
ad45ff
'hy
ad45ff
.PP
ad45ff
A meta expression refers to meta data associated with a packet.
ad45ff
.PP
ad45ff
There are two types of meta expressions: unqualified and qualified meta expressions.
ad45ff
Qualified meta expressions require the \fBmeta\fR keyword before the
ad45ff
meta key, unqualified meta expressions can be specified by using the meta key directly
ad45ff
or as qualified meta expressions.
ad45ff
.PP
ad45ff
\fBMeta expression types\fR
ad45ff
.TS
ad45ff
allbox ;
ad45ff
l | l | l.
ad45ff
T{
ad45ff
Keyword
ad45ff
T}	T{
ad45ff
Description
ad45ff
T}	T{
ad45ff
Type
ad45ff
T}
ad45ff
.T&
ad45ff
l | l | l.
ad45ff
T{
ad45ff
length
ad45ff
T}	T{
ad45ff
Length of the packet in bytes
ad45ff
T}	T{
ad45ff
integer (32 bit)
ad45ff
T}
ad45ff
T{
ad45ff
nfproto
ad45ff
T}	T{
ad45ff
real hook protocol family, useful only in inet table
ad45ff
T}	T{
ad45ff
integer (32 bit)
ad45ff
T}
ad45ff
T{
ad45ff
protocol
ad45ff
T}	T{
ad45ff
Ethertype protocol value
ad45ff
T}	T{
ad45ff
ether_type
ad45ff
T}
ad45ff
T{
ad45ff
priority
ad45ff
T}	T{
ad45ff
TC packet priority
ad45ff
T}	T{
ad45ff
tc_handle
ad45ff
T}
ad45ff
T{
ad45ff
mark
ad45ff
T}	T{
ad45ff
Packet mark
ad45ff
T}	T{
ad45ff
mark
ad45ff
T}
ad45ff
T{
ad45ff
iif
ad45ff
T}	T{
ad45ff
Input interface index
ad45ff
T}	T{
ad45ff
iface_index
ad45ff
T}
ad45ff
T{
ad45ff
iifname
ad45ff
T}	T{
ad45ff
Input interface name
ad45ff
T}	T{
ad45ff
string
ad45ff
T}
ad45ff
T{
ad45ff
iiftype
ad45ff
T}	T{
ad45ff
Input interface type
ad45ff
T}	T{
ad45ff
iface_type
ad45ff
T}
ad45ff
T{
ad45ff
oif
ad45ff
T}	T{
ad45ff
Output interface index
ad45ff
T}	T{
ad45ff
iface_index
ad45ff
T}
ad45ff
T{
ad45ff
oifname
ad45ff
T}	T{
ad45ff
Output interface name
ad45ff
T}	T{
ad45ff
string
ad45ff
T}
ad45ff
T{
ad45ff
oiftype