'\" t -*- coding: us-ascii -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH nft 8 "22 December 2016" "" "" .SH NAME nft \- Administration tool for packet filtering and classification .SH SYNOPSIS 'nh .fi .ad l \fBnft\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [ \fB-n | --numeric\fR ] [ \fB[-I | --includepath]\fR \fIdirectory\fR ] [ \fB[-f | --file]\fR \fIfilename\fR | \fB[-i | --interactive]\fR | \fIcmd\fR \&...] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBnft\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [ \fB-h | --help\fR ] [ \fB-v | --version\fR ] 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION nft is used to set up, maintain and inspect packet filtering and classification rules in the Linux kernel. .SH OPTIONS For a full summary of options, run \fBnft --help\fR. .TP \*(T<\fB\-h, \-\-help\fR\*(T> Show help message and all options. .TP \*(T<\fB\-v, \-\-version\fR\*(T> Show version. .TP \*(T<\fB\-n, \-\-numeric\fR\*(T> Show data numerically. When used once (the default behaviour), skip lookup of addresses to symbolic names. Use twice to also show Internet services (port numbers) numerically. Use three times to also show protocols and UIDs/GIDs numerically. .TP \*(T<\fB\-N\fR\*(T> Translate IP addresses to names. Usually requires network traffic for DNS lookup. .TP \*(T<\fB\-a, \-\-handle\fR\*(T> Show rule handles in output. .TP \*(T<\fB\-I, \-\-includepath \fR\*(T>\fIdirectory\fR Add the directory \fIdirectory\fR to the list of directories to be searched for included files. .TP \*(T<\fB\-f, \-\-file \fR\*(T>\fIfilename\fR Read input from \fIfilename\fR. .TP \*(T<\fB\-i, \-\-interactive\fR\*(T> Read input from an interactive readline CLI. .SH "INPUT FILE FORMAT" .SS "LEXICAL CONVENTIONS" Input is parsed line-wise. When the last character of a line, just before the newline character, is a non-quoted backslash (\*(T<\e\*(T>), the next line is treated as a continuation. Multiple commands on the same line can be separated using a semicolon (\*(T<;\*(T>). .PP A hash sign (\*(T<#\*(T>) begins a comment. All following characters on the same line are ignored. .PP Identifiers begin with an alphabetic character (\*(T), followed zero or more alphanumeric characters (\*(T) and the characters slash (\*(T), backslash (\*(T<\e\*(T>), underscore (\*(T<_\*(T>) and dot (\*(T<.\*(T>). Identifiers using different characters or clashing with a keyword need to be enclosed in double quotes (\*(T<"\*(T>). .PP .SS "INCLUDE FILES" 'nh .fi .ad l \fBinclude\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu \fIfilename\fR 'in \n(.iu-\nxu .ad b 'hy .PP Other files can be included by using the \fBinclude\fR statement. The directories to be searched for include files can be specified using the \*(T<\fB\-I/\-\-includepath\fR\*(T> option. .SS "SYMBOLIC VARIABLES" 'nh .fi .ad l \fBdefine\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu variable \fIexpr\fR 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fB$variable\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu 'in \n(.iu-\nxu .ad b 'hy .PP Symbolic variables can be defined using the \fBdefine\fR statement. Variable references are expressions and can be used initialize other variables. The scope of a definition is the current block and all blocks contained within. \fBUsing symbolic variables\fR .PP .nf \*(T< define int_if1 = eth0 define int_if2 = eth1 define int_ifs = { $int_if1, $int_if2 } filter input iif $int_ifs accept \*(T> .fi .SH "ADDRESS FAMILIES" Address families determine the type of packets which are processed. For each address family the kernel contains so called hooks at specific stages of the packet processing paths, which invoke nftables if rules for these hooks exist. .PP .TP \*(T<\fBip\fR\*(T> IPv4 address family. .TP \*(T<\fBip6\fR\*(T> IPv6 address family. .TP \*(T<\fBinet\fR\*(T> Internet (IPv4/IPv6) address family. .TP \*(T<\fBarp\fR\*(T> ARP address family, handling packets vi .TP \*(T<\fBbridge\fR\*(T> Bridge address family, handling packets which traverse a bridge device. .TP \*(T<\fBnetdev\fR\*(T> Netdev address family, handling packets from ingress. .PP All nftables objects exist in address family specific namespaces, therefore all identifiers include an address family. If an identifier is specified without an address family, the \*(T family is used by default. .SS "IPV4/IPV6/INET ADDRESS FAMILIES" The IPv4/IPv6/Inet address families handle IPv4, IPv6 or both types of packets. They contain five hooks at different packet processing stages in the network stack. .PP \fBIPv4/IPv6/Inet address family hooks\fR .TS allbox ; l | l. T{ Hook T} T{ Description T} .T& l | l. T{ prerouting T} T{ All packets entering the system are processed by the prerouting hook. It is invoked before the routing process and is used for early filtering or changing packet attributes that affect routing. T} T{ input T} T{ Packets delivered to the local system are processed by the input hook. T} T{ forward T} T{ Packets forwarded to a different host are processed by the forward hook. T} T{ output T} T{ Packets sent by local processes are processed by the output hook. T} T{ postrouting T} T{ All packets leaving the system are processed by the postrouting hook. T} .TE .SS "ARP ADDRESS FAMILY" The ARP address family handles ARP packets received and sent by the system. It is commonly used to mangle ARP packets for clustering. .PP \fBARP address family hooks\fR .TS allbox ; l | l. T{ Hook T} T{ Description T} .T& l | l l | l. T{ input T} T{ Packets delivered to the local system are processed by the input hook. T} T{ output T} T{ Packets send by the local system are processed by the output hook. T} .TE .SS "BRIDGE ADDRESS FAMILY" The bridge address family handles ethernet packets traversing bridge devices. .SS "NETDEV ADDRESS FAMILY" The Netdev address family handles packets from ingress. .PP \fBNetdev address family hooks\fR .TS allbox ; l | l. T{ Hook T} T{ Description T} .T& l | l. T{ ingress T} T{ All packets entering the system are processed by this hook. It is invoked before layer 3 protocol handlers and it can be used for early filtering and policing. T} .TE .SH TABLES 'nh .fi .ad l {add | delete | list | flush} \fBtable\fR [\fIfamily\fR] {\fItable\fR} .ad b 'hy .PP Tables are containers for chains and sets. They are identified by their address family and their name. The address family must be one of \*(T, \*(T, \*(T, \*(T, \*(T, \*(T. The \*(T address family is a dummy family which is used to create hybrid IPv4/IPv6 tables. When no address family is specified, \*(T is used by default. .TP \*(T<\fBadd\fR\*(T> Add a new table for the given family with the given name. .TP \*(T<\fBdelete\fR\*(T> Delete the specified table. .TP \*(T<\fBlist\fR\*(T> List all chains and rules of the specified table. .TP \*(T<\fBflush\fR\*(T> Flush all chains and rules of the specified table. .SH CHAINS 'nh .fi .ad l {add} \fBchain\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {\fIhook\fR} {\fIpriority\fR} {\fIpolicy\fR} {\fIdevice\fR} .ad b 'hy 'nh .fi .ad l {add | create | delete | list | flush} \fBchain\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} .ad b 'hy 'nh .fi .ad l {rename} \fBchain\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {\fInewname\fR} .ad b 'hy .PP Chains are containers for rules. They exist in two kinds, base chains and regular chains. A base chain is an entry point for packets from the networking stack, a regular chain may be used as jump target and is used for better rule organization. .TP \*(T<\fBadd\fR\*(T> Add a new chain in the specified table. When a hook and priority value are specified, the chain is created as a base chain and hooked up to the networking stack. .TP \*(T<\fBcreate\fR\*(T> Simlar to the \fBadd\fR command, but returns an error if the chain already exists. .TP \*(T<\fBdelete\fR\*(T> Delete the specified chain. The chain must not contain any rules or be used as jump target. .TP \*(T<\fBrename\fR\*(T> Rename the specified chain. .TP \*(T<\fBlist\fR\*(T> List all rules of the specified chain. .TP \*(T<\fBflush\fR\*(T> Flush all rules of the specified chain. .SH RULES 'nh .fi .ad l [add | insert] \fBrule\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} [position \fIposition\fR] {\fIstatement\fR}\&... .ad b 'hy 'nh .fi .ad l {delete} \fBrule\fR [\fIfamily\fR] {\fItable\fR} {\fIchain\fR} {handle \fIhandle\fR} .ad b 'hy .PP Rules are constructed from two kinds of components according to a set of grammatical rules: expressions and statements. .TP \*(T<\fBadd\fR\*(T> Add a new rule described by the list of statements. The rule is appended to the given chain unless a position is specified, in which case the rule is appended to the rule given by the position. .TP \*(T<\fBinsert\fR\*(T> Similar to the \fBadd\fR command, but the rule is prepended to the beginning of the chain or before the rule at the given position. .TP \*(T<\fBdelete\fR\*(T> Delete the specified rule. .SH EXPRESSIONS Expressions represent values, either constants like network addresses, port numbers etc. or data gathered from the packet during ruleset evaluation. Expressions can be combined using binary, logical, relational and other types of expressions to form complex or relational (match) expressions. They are also used as arguments to certain types of operations, like NAT, packet marking etc. .PP Each expression has a data type, which determines the size, parsing and representation of symbolic values and type compatibility with other expressions. .SS "DESCRIBE COMMAND" 'nh .fi .ad l \fBdescribe\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {\fIexpression\fR} 'in \n(.iu-\nxu .ad b 'hy .PP The \fBdescribe\fR command shows information about the type of an expression and its data type. .PP \fBThe describe command\fR .PP .nf \*(T< $ nft describe tcp flags payload expression, datatype tcp_flag (TCP flag) (basetype bitmask, integer), 8 bits pre\-defined symbolic constants: fin 0x01 syn 0x02 rst 0x04 psh 0x08 ack 0x10 urg 0x20 ecn 0x40 cwr 0x80 \*(T> .fi .SH "DATA TYPES" Data types determine the size, parsing and representation of symbolic values and type compatibility of expressions. A number of global data types exist, in addition some expression types define further data types specific to the expression type. Most data types have a fixed size, some however may have a dynamic size, f.i. the string type. .PP Types may be derived from lower order types, f.i. the IPv4 address type is derived from the integer type, meaning an IPv4 address can also be specified as an integer value. .PP In certain contexts (set and map definitions) it is necessary to explicitly specify a data type. Each type has a name which is used for this. .SS "INTEGER TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ Integer T} T{ integer T} T{ variable T} T{ - T} .TE .PP The integer type is used for numeric values. It may be specified as decimal, hexadecimal or octal number. The integer type doesn't have a fixed size, its size is determined by the expression for which it is used. .SS "BITMASK TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ Bitmask T} T{ bitmask T} T{ variable T} T{ integer T} .TE .PP The bitmask type (\fBbitmask\fR) is used for bitmasks. .SS "STRING TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ String T} T{ string T} T{ variable T} T{ - T} .TE .PP The string type is used to for character strings. A string begins with an alphabetic character (a-zA-Z) followed by zero or more alphanumeric characters or the characters \*(T, \*(T<\-\*(T>, \*(T<_\*(T> and \*(T<.\*(T>. In addition anything enclosed in double quotes (\*(T<"\*(T>) is recognized as a string. .PP \fBString specification\fR .PP .nf \*(T< # Interface name filter input iifname eth0 # Weird interface name filter input iifname "(eth0)" \*(T> .fi .SS "LINK LAYER ADDRESS TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ Link layer address T} T{ lladdr T} T{ variable T} T{ integer T} .TE .PP The link layer address type is used for link layer addresses. Link layer addresses are specified as a variable amount of groups of two hexadecimal digits separated using colons (\*(T<:\*(T>). .PP \fBLink layer address specification\fR .PP .nf \*(T< # Ethernet destination MAC address filter input ether daddr 20:c9:d0:43:12:d9 \*(T> .fi .SS "IPV4 ADDRESS TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ IPv4 address T} T{ ipv4_addr T} T{ 32 bit T} T{ integer T} .TE .PP The IPv4 address type is used for IPv4 addresses. Addresses are specified in either dotted decimal, dotted hexadecimal, dotted octal, decimal, hexadecimal, octal notation or as a host name. A host name will be resolved using the standard system resolver. .PP \fBIPv4 address specification\fR .PP .nf \*(T< # dotted decimal notation filter output ip daddr 127.0.0.1 # host name filter output ip daddr localhost \*(T> .fi .SS "IPV6 ADDRESS TYPE" .TS allbox ; l | l | l | l. T{ Name T} T{ Keyword T} T{ Size T} T{ Base type T} .T& l | l | l | l. T{ IPv6 address T} T{ ipv6_addr T} T{ 128 bit T} T{ integer T} .TE .PP The IPv6 address type is used for IPv6 addresses. FIXME .PP \fBIPv6 address specification\fR .PP .nf \*(T< # abbreviated loopback address filter output ip6 daddr ::1 \*(T> .fi .SH "PRIMARY EXPRESSIONS" The lowest order expression is a primary expression, representing either a constant or a single datum from a packet's payload, meta data or a stateful module. .SS "META EXPRESSIONS" 'nh .fi .ad l \fBmeta\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {length | nfproto | l4proto | protocol | priority} 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l [meta] {mark | iif | iifname | iiftype | oif | oifname | oiftype | skuid | skgid | nftrace | rtclassid | ibriport | obriport | pkttype | cpu | iifgroup | oifgroup | cgroup | random} .ad b 'hy .PP A meta expression refers to meta data associated with a packet. .PP There are two types of meta expressions: unqualified and qualified meta expressions. Qualified meta expressions require the \fBmeta\fR keyword before the meta key, unqualified meta expressions can be specified by using the meta key directly or as qualified meta expressions. .PP \fBMeta expression types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ length T} T{ Length of the packet in bytes T} T{ integer (32 bit) T} T{ protocol T} T{ Ethertype protocol value T} T{ ether_type T} T{ priority T} T{ TC packet priority T} T{ tc_handle T} T{ mark T} T{ Packet mark T} T{ mark T} T{ iif T} T{ Input interface index T} T{ iface_index T} T{ iifname T} T{ Input interface name T} T{ string T} T{ iiftype T} T{ Input interface type T} T{ iface_type T} T{ oif T} T{ Output interface index T} T{ iface_index T} T{ oifname T} T{ Output interface name T} T{ string T} T{ oiftype T} T{ Output interface hardware type T} T{ iface_type T} T{ skuid T} T{ UID associated with originating socket T} T{ uid T} T{ skgid T} T{ GID associated with originating socket T} T{ gid T} T{ rtclassid T} T{ Routing realm T} T{ realm T} T{ ibriport T} T{ Input bridge interface name T} T{ string T} T{ obriport T} T{ Output bridge interface name T} T{ string T} T{ pkttype T} T{ packet type T} T{ pkt_type T} T{ cpu T} T{ cpu number processing the packet T} T{ integer (32 bits) T} T{ iifgroup T} T{ incoming device group T} T{ devgroup T} T{ oifgroup T} T{ outgoing device group T} T{ devgroup T} T{ cgroup T} T{ control group id T} T{ integer (32 bits) T} T{ random T} T{ pseudo-random number T} T{ integer (32 bits) T} .TE .PP \fBMeta expression specific types\fR .TS allbox ; l | l. T{ Type T} T{ Description T} .T& l | l. T{ iface_index T} T{ Interface index (32 bit number). Can be specified numerically or as name of an existing interface. T} T{ ifname T} T{ Interface name (16 byte string). Does not have to exist. T} T{ iface_type T} T{ Interface type (16 bit number). T} T{ uid T} T{ User ID (32 bit number). Can be specified numerically or as user name. T} T{ gid T} T{ Group ID (32 bit number). Can be specified numerically or as group name. T} T{ realm T} T{ Routing Realm (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms. T} T{ devgroup_type T} T{ Device group (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/group. T} T{ pkt_type T} T{ Packet type: Unicast (addressed to local host), Broadcast (to all), Multicast (to group). T} .TE .PP \fBUsing meta expressions\fR .PP .nf \*(T< # qualified meta expression filter output meta oif eth0 # unqualified meta expression filter output oif eth0 \*(T> .fi .SS "FIB EXPRESSIONS" 'nh .fi .ad l \fBfib\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {saddr | daddr | [mark | iif | oif]} {oif | oifname | type} 'in \n(.iu-\nxu .ad b 'hy .PP A fib expression queries the fib (forwarding information base) to obtain information such as the output interface index a particular address would use. The input is a tuple of elements that is used as input to the fib lookup functions. .PP \fBfib expression specific types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l l | l | l. T{ oif T} T{ Output interface index T} T{ integer (32 bit) T} T{ oifname T} T{ Output interface name T} T{ string T} T{ type T} T{ Address type T} T{ fib_addrtype T} .TE .PP \fBUsing fib expressions\fR .PP .nf \*(T< # drop packets without a reverse path filter prerouting fib saddr . iif oif eq 0 drop # drop packets to address not configured on ininterface filter input fib daddr . iif type not { local, broadcast, multicast } drop # perform lookup in a specific 'blackhole' table (0xdead, needs ip appropriate ip rule) filter prerouting meta mark set 0xdead fib daddr . mark type vmap { backhole : drop, prohibit : jump prohibited, unreachable : drop } \*(T> .fi .SS "ROUTING EXPRESSIONS" 'nh .fi .ad l \fBrt\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {classid | nexthop} 'in \n(.iu-\nxu .ad b 'hy .PP A routing expression refers to routing data associated with a packet. .PP \fBRouting expression types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l. T{ classid T} T{ Routing realm T} T{ realm T} T{ nexthop T} T{ Routing nexthop T} T{ ipv4_addr/ipv6_addr T} .TE .PP \fBRouting expression specific types\fR .TS allbox ; l | l. T{ Type T} T{ Description T} .T& l | l. T{ realm T} T{ Routing Realm (32 bit number). Can be specified numerically or as symbolic name defined in /etc/iproute2/rt_realms. T} .TE .PP \fBUsing routing expressions\fR .PP .nf \*(T< # IP family independent rt expression filter output rt classid 10 # IP family dependent rt expressions ip filter output rt nexthop 192.168.0.1 ip6 filter output rt nexthop fd00::1 inet filter meta nfproto ipv4 output rt nexthop 192.168.0.1 inet filter meta nfproto ipv6 output rt nexthop fd00::1 \*(T> .fi .SH "PAYLOAD EXPRESSIONS" Payload expressions refer to data from the packet's payload. .SS "ETHERNET HEADER EXPRESSION" 'nh .fi .ad l \fBether\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIethernet header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBEthernet header expression types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l l | l | l. T{ daddr T} T{ Destination MAC address T} T{ ether_addr T} T{ saddr T} T{ Source MAC address T} T{ ether_addr T} T{ type T} T{ EtherType T} T{ ether_type T} .TE .SS "VLAN HEADER EXPRESSION" 'nh .fi .ad l \fBvlan\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIVLAN header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBVLAN header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ id T} T{ VLAN ID (VID) T} T{ integer (12 bit) T} T{ cfi T} T{ Canonical Format Indicator T} T{ integer (1 bit) T} T{ pcp T} T{ Priority code point T} T{ integer (3 bit) T} T{ type T} T{ EtherType T} T{ ether_type T} .TE .SS "ARP HEADER EXPRESSION" 'nh .fi .ad l \fBarp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIARP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBARP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ htype T} T{ ARP hardware type T} T{ integer (16 bit) T} T{ ptype T} T{ EtherType T} T{ ether_type T} T{ hlen T} T{ Hardware address len T} T{ integer (8 bit) T} T{ plen T} T{ Protocol address len T} T{ integer (8 bit) T} T{ operation T} T{ Operation T} T{ arp_op T} .TE .SS "IPV4 HEADER EXPRESSION" 'nh .fi .ad l \fBip\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIIPv4 header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBIPv4 header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ version T} T{ IP header version (4) T} T{ integer (4 bit) T} T{ hdrlength T} T{ IP header length including options T} T{ integer (4 bit) FIXME scaling T} T{ dscp T} T{ Differentiated Services Code Point T} T{ dscp T} T{ ecn T} T{ Explicit Congestion Notification T} T{ ecn T} T{ length T} T{ Total packet length T} T{ integer (16 bit) T} T{ id T} T{ IP ID T} T{ integer (16 bit) T} T{ frag-off T} T{ Fragment offset T} T{ integer (16 bit) T} T{ ttl T} T{ Time to live T} T{ integer (8 bit) T} T{ protocol T} T{ Upper layer protocol T} T{ inet_proto T} T{ checksum T} T{ IP header checksum T} T{ integer (16 bit) T} T{ saddr T} T{ Source address T} T{ ipv4_addr T} T{ daddr T} T{ Destination address T} T{ ipv4_addr T} .TE .SS "IPV6 HEADER EXPRESSION" 'nh .fi .ad l \fBip6\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIIPv6 header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBIPv6 header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ version T} T{ IP header version (6) T} T{ integer (4 bit) T} T{ dscp T} T{ Differentiated Services Code Point T} T{ dscp T} T{ ecn T} T{ Explicit Congestion Notification T} T{ ecn T} T{ flowlabel T} T{ Flow label T} T{ integer (20 bit) T} T{ length T} T{ Payload length T} T{ integer (16 bit) T} T{ nexthdr T} T{ Nexthdr protocol T} T{ inet_proto T} T{ hoplimit T} T{ Hop limit T} T{ integer (8 bit) T} T{ saddr T} T{ Source address T} T{ ipv6_addr T} T{ daddr T} T{ Destination address T} T{ ipv6_addr T} .TE .SS "TCP HEADER EXPRESSION" 'nh .fi .ad l \fBtcp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fITCP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBTCP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ sport T} T{ Source port T} T{ inet_service T} T{ dport T} T{ Destination port T} T{ inet_service T} T{ sequence T} T{ Sequence number T} T{ integer (32 bit) T} T{ ackseq T} T{ Acknowledgement number T} T{ integer (32 bit) T} T{ doff T} T{ Data offset T} T{ integer (4 bit) FIXME scaling T} T{ reserved T} T{ Reserved area T} T{ integer (4 bit) T} T{ flags T} T{ TCP flags T} T{ tcp_flag T} T{ window T} T{ Window T} T{ integer (16 bit) T} T{ checksum T} T{ Checksum T} T{ integer (16 bit) T} T{ urgptr T} T{ Urgent pointer T} T{ integer (16 bit) T} .TE .SS "UDP HEADER EXPRESSION" 'nh .fi .ad l \fBudp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIUDP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBUDP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ sport T} T{ Source port T} T{ inet_service T} T{ dport T} T{ Destination port T} T{ inet_service T} T{ length T} T{ Total packet length T} T{ integer (16 bit) T} T{ checksum T} T{ Checksum T} T{ integer (16 bit) T} .TE .SS "UDP-LITE HEADER EXPRESSION" 'nh .fi .ad l \fBudplite\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIUDP-Lite header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBUDP-Lite header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l l | l | l. T{ sport T} T{ Source port T} T{ inet_service T} T{ dport T} T{ Destination port T} T{ inet_service T} T{ checksum T} T{ Checksum T} T{ integer (16 bit) T} .TE .SS "SCTP HEADER EXPRESSION" 'nh .fi .ad l \fBsctp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fISCTP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBSCTP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ sport T} T{ Source port T} T{ inet_service T} T{ dport T} T{ Destination port T} T{ inet_service T} T{ vtag T} T{ Verfication Tag T} T{ integer (32 bit) T} T{ checksum T} T{ Checksum T} T{ integer (32 bit) T} .TE .SS "DCCP HEADER EXPRESSION" 'nh .fi .ad l \fBdccp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIDCCP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBDCCP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l. T{ sport T} T{ Source port T} T{ inet_service T} T{ dport T} T{ Destination port T} T{ inet_service T} .TE .SS "AUTHENTICATION HEADER EXPRESSION" 'nh .fi .ad l \fBah\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIAH header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBAH header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ nexthdr T} T{ Next header protocol T} T{ inet_proto T} T{ hdrlength T} T{ AH Header length T} T{ integer (8 bit) T} T{ reserved T} T{ Reserved area T} T{ integer (16 bit) T} T{ spi T} T{ Security Parameter Index T} T{ integer (32 bit) T} T{ sequence T} T{ Sequence number T} T{ integer (32 bit) T} .TE .SS "ENCRYPTED SECURITY PAYLOAD HEADER EXPRESSION" 'nh .fi .ad l \fBesp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIESP header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBESP header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l. T{ spi T} T{ Security Parameter Index T} T{ integer (32 bit) T} T{ sequence T} T{ Sequence number T} T{ integer (32 bit) T} .TE .SS "IPCOMP HEADER EXPRESSION" 'nh .fi .ad l \fBcomp\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fIIPComp header field\fR] 'in \n(.iu-\nxu .ad b 'hy .PP \fBIPComp header expression\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l l | l | l l | l | l. T{ nexthdr T} T{ Next header protocol T} T{ inet_proto T} T{ flags T} T{ Flags T} T{ bitmask T} T{ cpi T} T{ Compression Parameter Index T} T{ integer (16 bit) T} .TE .SH BLA .SS "IPV6 EXTENSION HEADER EXPRESSIONS" IPv6 extension header expressions refer to data from an IPv6 packet's extension headers. .SS "CONNTRACK EXPRESSIONS" Conntrack expressions refer to meta data of the connection tracking entry associated with a packet. .PP There are three types of conntrack expressions. Some conntrack expressions require the flow direction before the conntrack key, others must be used directly because they are direction agnostic. The \fBpackets and bytes\fR keywords can be used with or without a direction. If the direction is omitted, the sum of the original and the reply direction is returned. .PP 'nh .fi .ad l \fBct\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {state | direction | status | mark | expiration | helper | label | l3proto | protocol | bytes | packets} 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBct\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {original | reply} {l3proto | protocol | saddr | daddr | proto-src | proto-dst | bytes | packets} 'in \n(.iu-\nxu .ad b 'hy .PP \fBConntrack expressions\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ state T} T{ State of the connection T} T{ ct_state T} T{ direction T} T{ Direction of the packet relative to the connection T} T{ ct_dir T} T{ status T} T{ Status of the connection T} T{ ct_status T} T{ mark T} T{ Connection mark T} T{ mark T} T{ expiration T} T{ Connection expiration time T} T{ time T} T{ helper T} T{ Helper associated with the connection T} T{ string T} T{ label T} T{ Connection tracking label bit or symbolic name defined in connlabel.conf in the nftables include path T} T{ ct_label T} T{ l3proto T} T{ Layer 3 protocol of the connection T} T{ nf_proto T} T{ saddr T} T{ Source address of the connection for the given direction T} T{ ipv4_addr/ipv6_addr T} T{ daddr T} T{ Destination address of the connection for the given direction T} T{ ipv4_addr/ipv6_addr T} T{ protocol T} T{ Layer 4 protocol of the connection for the given direction T} T{ inet_proto T} T{ proto-src T} T{ Layer 4 protocol source for the given direction T} T{ integer (16 bit) T} T{ proto-dst T} T{ Layer 4 protocol destination for the given direction T} T{ integer (16 bit) T} T{ packets T} T{ packet count seen in the given direction or sum of original and reply T} T{ integer (64 bit) T} T{ bytes T} T{ bytecount seen, see description for \fBpackets\fR keyword T} T{ integer (64 bit) T} .TE .SH STATEMENTS Statements represent actions to be performed. They can alter control flow (return, jump to a different chain, accept or drop the packet) or can perform actions, such as logging, rejecting a packet, etc. .PP Statements exist in two kinds. Terminal statements unconditionally terminate evaluation of the current rule, non-terminal statements either only conditionally or never terminate evaluation of the current rule, in other words, they are passive from the ruleset evaluation perspective. There can be an arbitrary amount of non-terminal statements in a rule, but only a single terminal statement as the final statement. .SS "VERDICT STATEMENT" The verdict statement alters control flow in the ruleset and issues policy decisions for packets. .PP 'nh .fi .ad l {accept | drop | queue | continue | return} .ad b 'hy 'nh .fi .ad l {jump | goto} {\fIchain\fR} .ad b 'hy .PP .TP \*(T<\fBaccept\fR\*(T> Terminate ruleset evaluation and accept the packet. .TP \*(T<\fBdrop\fR\*(T> Terminate ruleset evaluation and drop the packet. .TP \*(T<\fBqueue\fR\*(T> Terminate ruleset evaluation and queue the packet to userspace. .TP \*(T<\fBcontinue\fR\*(T> Continue ruleset evaluation with the next rule. FIXME .TP \*(T<\fBreturn\fR\*(T> Return from the current chain and continue evaluation at the next rule in the last chain. If issued in a base chain, it is equivalent to \fBaccept\fR. .TP \*(T<\fBjump \fR\*(T>\fIchain\fR Continue evaluation at the first rule in \fIchain\fR. The current position in the ruleset is pushed to a call stack and evaluation will continue there when the new chain is entirely evaluated of a \fBreturn\fR verdict is issued. .TP \*(T<\fBgoto \fR\*(T>\fIchain\fR Similar to \fBjump\fR, but the current position is not pushed to the call stack, meaning that after the new chain evaluation will continue at the last chain instead of the one containing the goto statement. .PP \fBVerdict statements\fR .PP .nf \*(T< # process packets from eth0 and the internal network in from_lan # chain, drop all packets from eth0 with different source addresses. filter input iif eth0 ip saddr 192.168.0.0/24 jump from_lan filter input iif eth0 drop \*(T> .fi .SS "PAYLOAD STATEMENT" The payload statement alters packet content. It can be used for example to set ip DSCP (differv) header field or ipv6 flow labels. .PP \fBroute some packets instead of bridging\fR .PP .nf \*(T< # redirect tcp:http from 192.160.0.0/16 to local machine for routing instead of bridging # assumes 00:11:22:33:44:55 is local MAC address. bridge 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 \*(T> .fi .PP \fBSet IPv4 DSCP header field\fR .PP .nf \*(T< ip forward ip dscp set 42 \*(T> .fi .SS "LOG STATEMENT" 'nh .fi .ad l \fBlog\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [prefix \fIquoted_string\fR] [level \fIsyslog-level\fR] [flags \fIlog-flags\fR] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBlog\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu group \fInflog_group\fR [prefix \fIquoted_string\fR] [queue-threshold \fIvalue\fR] [snaplen \fIsize\fR] 'in \n(.iu-\nxu .ad b 'hy .PP The log statement enables logging of matching packets. When this statement is used from a rule, the Linux kernel will print some information on all matching packets, such as header fields, via the kernel log (where it can be read with dmesg(1) or read in the syslog). If the group number is specified, the Linux kernel will pass the packet to nfnetlink_log which will multicast the packet through a netlink socket to the specified multicast group. One or more userspace processes may subscribe to the group to receive the packets, see libnetfilter_queue documentation for details. This is a non-terminating statement, so the rule evaluation continues after the packet is logged. .PP \fBlog statement options\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Type T} .T& l | l | l. T{ prefix T} T{ Log message prefix T} T{ quoted string T} T{ syslog-level T} T{ Syslog level of logging T} T{ string: emerg, alert, crit, err, warn [default], notice, info, debug T} T{ group T} T{ NFLOG group to send messages to T} T{ unsigned integer (16 bit) T} T{ snaplen T} T{ Length of packet payload to include in netlink message T} T{ unsigned integer (32 bit) T} T{ queue-threshold T} T{ Number of packets to queue inside the kernel before sending them to userspace T} T{ unsigned integer (32 bit) T} .TE .PP \fBlog-flags\fR .TS allbox ; l | l. T{ Flag T} T{ Description T} .T& l | l. T{ tcp sequence T} T{ Log TCP sequence numbers. T} T{ tcp options T} T{ Log options from the TCP packet header. T} T{ ip options T} T{ Log options from the IP/IPv6 packet header. T} T{ skuid T} T{ Log the userid of the process which generated the packet. T} T{ ether T} T{ Decode MAC addresses and protocol. T} T{ all T} T{ Enable all log flags listed above. T} .TE .PP \fBUsing log statement\fR .PP .nf \*(T< # log the UID which generated the packet and ip options ip filter output log flags skuid flags ip options # log the tcp sequence numbers and tcp options from the TCP packet ip filter output log flags tcp sequence,options # enable all supported log flags ip6 filter output log flags all \*(T> .fi .SS "REJECT STATEMENT" 'nh .fi .ad l \fBreject\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu with {icmp | icmp6 | icmpx} type {icmp_type | icmp6_type | icmpx_type} 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBreject\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu with {tcp} {reset} 'in \n(.iu-\nxu .ad b 'hy .PP A reject statement is used to send back an error packet in response to the matched packet otherwise it is equivalent to drop so it is a terminating statement, ending rule traversal. This statement is only valid in the input, forward and output chains, and user-defined chains which are only called from those chains. \fBreject statement type (ip)\fR .TS allbox ; l | l | l. T{ Value T} T{ Description T} T{ Type T} .T& l | l | l. T{ icmp_type T} T{ ICMP type response to be sent to the host T} T{ net-unreachable, host-unreachable, prot-unreachable, port-unreachable [default], net-prohibited, host-prohibited, admin-prohibited T} .TE .PP \fBreject statement type (ip6)\fR .TS allbox ; l | l | l. T{ Value T} T{ Description T} T{ Type T} .T& l | l | l. T{ icmp6_type T} T{ ICMPv6 type response to be sent to the host T} T{ no-route, admin-prohibited, addr-unreachable, port-unreachable [default], policy-fail, reject-route T} .TE .PP \fBreject statement type (inet)\fR .TS allbox ; l | l | l. T{ Value T} T{ Description T} T{ Type T} .T& l | l | l. T{ icmpx_type T} T{ ICMPvXtype abstraction response to be sent to the host, this is a set of types that overlap in IPv4 and IPv6 to be used from the inet family. T} T{ port-unreachable [default], admin-prohibited, no-route, host-unreachable T} .TE .SS "COUNTER STATEMENT" A counter statement sets the hit count of packets along with the number of bytes. .PP 'nh .fi .ad l \fBcounter\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {packets \fInumber\fR } {bytes \fInumber\fR } 'in \n(.iu-\nxu .ad b 'hy .SS "CONNTRACK STATEMENT" The conntrack statement can be used to set the conntrack mark and conntrack labels. .PP 'nh .fi .ad l \fBct\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {mark | label} set \fIvalue\fR 'in \n(.iu-\nxu .ad b 'hy .PP The ct statement sets meta data associated with a connection. .PP \fBMeta statement types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Value T} .T& l | l | l l | l | l. T{ mark T} T{ Connection tracking mark T} T{ mark T} T{ label T} T{ Connection tracking label T} T{ label T} .TE .PP \fBsave packet nfmark in conntrack\fR .PP .nf \*(T< ct set mark meta mark \*(T> .fi .SS "META STATEMENT" A meta statement sets the value of a meta expression. The existing meta fields are: priority, mark, pkttype, nftrace. .PP 'nh .fi .ad l \fBmeta\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu {mark | priority | pkttype | nftrace} set \fIvalue\fR 'in \n(.iu-\nxu .ad b 'hy .PP A meta statement sets meta data associated with a packet. .PP \fBMeta statement types\fR .TS allbox ; l | l | l. T{ Keyword T} T{ Description T} T{ Value T} .T& l | l | l. T{ priority T} T{ TC packet priority T} T{ tc_handle T} T{ mark T} T{ Packet mark T} T{ mark T} T{ pkttype T} T{ packet type T} T{ pkt_type T} T{ nftrace T} T{ ruleset packet tracing on/off. Use \fBmonitor trace\fR command to watch traces T} T{ 0, 1 T} .TE .SS "LIMIT STATEMENT" 'nh .fi .ad l \fBlimit\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu rate [over] \fIpacket_number\fR / {second | minute | hour | day} [burst \fIpacket_number\fR packets] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBlimit\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu rate [over] \fIbyte_number\fR {bytes | kbytes | mbytes} / {second | minute | hour | day | week} [burst \fIbyte_number\fR bytes] 'in \n(.iu-\nxu .ad b 'hy .PP A limit statement matches at a limited rate using a token bucket filter. A rule using this statement will match until this limit is reached. It can be used in combination with the log statement to give limited logging. The \fBover\fR keyword, that is optional, makes it match over the specified rate. .PP \fBlimit statement values\fR .TS allbox ; l | l | l. T{ Value T} T{ Description T} T{ Type T} .T& l | l | l l | l | l. T{ packet_number T} T{ Number of packets T} T{ unsigned integer (32 bit) T} T{ byte_number T} T{ Number of bytes T} T{ unsigned integer (32 bit) T} .TE .SS "NAT STATEMENTS" 'nh .fi .ad l \fBsnat\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu to \fIaddress\fR [:port] [persistent, random, fully-random] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBsnat\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu to \fIaddress\fR - \fIaddress\fR [:\fIport\fR - \fIport\fR] [persistent, random, fully-random] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBdnat\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu to \fIaddress\fR [:\fIport\fR] [persistent, random, fully-random] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBdnat\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu to \fIaddress\fR [:\fIport\fR - \fIport\fR] [persistent, random, fully-random] 'in \n(.iu-\nxu .ad b 'hy .PP The nat statements are only valid from nat chain types. .PP The \fBsnat\fR statement is only valid in the postrouting and input hooks, it specifies that the source address of the packet should be modified. The \fBdnat\fR statement is only valid in the prerouting and output chains, it specifies that the destination address of the packet should be modified. You can use non-base chains which are called from base chains of nat chain type too. All future packets in this connection will also be mangled, and rules should cease being examined. .PP \fBNAT statement values\fR .TS allbox ; l | l | l. T{ Expression T} T{ Description T} T{ Type T} .T& l | l | l l | l | l. T{ address T} T{ Specifies that the source/destination address of the packet should be modified. You may specify a mapping to relate a list of tuples composed of arbitrary expression key with address value. T} T{ ipv4_addr, ipv6_addr, eg. abcd::1234, or you can use a mapping, eg. meta mark map { 10 : 192.168.1.2, 20 : 192.168.1.3 } T} T{ port T} T{ Specifies that the source/destination address of the packet should be modified. T} T{ port number (16 bits) T} .TE .PP \fBNAT statement flags\fR .TS allbox ; l | l. T{ Flag T} T{ Description T} .T& l | l l | l l | l. T{ persistent T} T{ Gives a client the same source-/destination-address for each connection. T} T{ random T} T{ If used then port mapping will be randomized using a random seeded MD5 hash mix using source and destination address and destination port. T} T{ fully-random T} T{ If used then port mapping is generated based on a 32-bit pseudo-random algorithm. T} .TE .SS "QUEUE STATEMENT" This statement passes the packet to userspace using the nfnetlink_queue handler. The packet is put into the queue identified by its 16-bit queue number. Userspace can inspect and modify the packet if desired. Userspace must then drop or reinject the packet into the kernel. See libnetfilter_queue documentation for details. .PP 'nh .fi .ad l \fBqueue\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [num \fIqueue_number\fR] [bypass] 'in \n(.iu-\nxu .ad b 'hy 'nh .fi .ad l \fBqueue\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [num \fIqueue_number_from\fR - \fIqueue_number_to\fR] [bypass,fanout] 'in \n(.iu-\nxu .ad b 'hy .PP \fBqueue statement values\fR .TS allbox ; l | l | l. T{ Value T} T{ Description T} T{ Type T} .T& l | l | l l | l | l l | l | l. T{ queue_number T} T{ Sets queue number, default is 0. T} T{ unsigned integer (16 bit) T} T{ queue_number_from T} T{ Sets initial queue in the range, if fanout is used. T} T{ unsigned integer (16 bit) T} T{ queue_number_to T} T{ Sets closing queue in the range, if fanout is used. T} T{ unsigned integer (16 bit) T} .TE .PP \fBqueue statement flags\fR .TS allbox ; l | l. T{ Flag T} T{ Description T} .T& l | l l | l. T{ bypass T} T{ Let packets go through if userspace application cannot back off. Before using this flag, read libnetfilter_queue documentation for performance tuning recomendations. T} T{ fanout T} T{ Distribute packets between several queues. T} .TE .SH "ADDITIONAL COMMANDS" These are some additional commands included in nft. .SS EXPORT Export your current ruleset in XML or JSON format to stdout. .PP Examples: .nf \*(T< % nft export xml [...] % nft export json [...] \*(T> .fi .SS MONITOR The monitor command allows you to listen to Netlink events produced by the nf_tables subsystem, related to creation and deletion of objects. When they ocurr, nft will print to stdout the monitored events in either XML, JSON or native nft format. .PP To filter events related to a concrete object, use one of the keywords 'tables', 'chains', 'sets', 'rules', 'elements'. .PP To filter events related to a concrete action, use keyword 'new' or 'destroy'. .PP Hit ^C to finish the monitor operation. .PP \fBListen to all events, report in native nft format\fR .PP .nf \*(T< % nft monitor \*(T> .fi .PP \fBListen to added tables, report in XML format\fR .PP .nf \*(T< % nft monitor new tables xml \*(T> .fi .PP \fBListen to deleted rules, report in JSON format\fR .PP .nf \*(T< % nft monitor destroy rules json \*(T> .fi .PP \fBListen to both new and destroyed chains, in native nft format\fR .PP .nf \*(T< % nft monitor chains \*(T> .fi .SH "ERROR REPORTING" When an error is detected, nft shows the line(s) containing the error, the position of the erroneous parts in the input stream and marks up the erroneous parts using carrets (\*(T<^\*(T>). If the error results from the combination of two expressions or statements, the part imposing the constraints which are violated is marked using tildes (\*(T<~\*(T>). .PP For errors returned by the kernel, nft can't detect which parts of the input caused the error and the entire command is marked. .PP \fBError caused by single incorrect expression\fR .PP .nf \*(T< :1:19\-22: Error: Interface does not exist filter output oif eth0 ^^^^ \*(T> .fi .PP \fBError caused by invalid combination of two expressions\fR .PP .nf \*(T< :1:28\-36: Error: Right hand side of relational expression (==) must be constant filter output tcp dport == tcp dport ~~ ^^^^^^^^^ \*(T> .fi .PP \fBError returned by the kernel\fR .PP .nf \*(T< :0:0\-23: Error: Could not process rule: Operation not permitted filter output oif wlan0 ^^^^^^^^^^^^^^^^^^^^^^^ \*(T> .fi .SH "EXIT STATUS" On success, nft exits with a status of 0. Unspecified errors cause it to exit with a status of 1, memory allocation errors with a status of 2, unable to open Netlink socket with 3. .SH "SEE ALSO" iptables(8), ip6tables(8), arptables(8), ebtables(8), ip(8), tc(8) .PP There is an official wiki at: http://wiki.nftables.org .SH AUTHORS nftables was written by Patrick McHardy and Pablo Neira Ayuso, among many other contributors from the Netfilter community. .SH COPYRIGHT .nf Copyright 2008\-2014 Patrick McHardy <\*(T> Copyright 2013\-2016 Pablo Neira Ayuso <\*(T> .fi .PP nftables is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. .PP This documentation is licenced under the terms of the Creative Commons Attribution-ShareAlike 4.0 license, .URL http://creativecommons.org/licenses/by-sa/4.0/ "CC BY-SA 4.0" \&.