<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.nftables.org/wiki-nftables/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Elise</id>
	<title>nftables wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.nftables.org/wiki-nftables/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Elise"/>
	<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php/Special:Contributions/Elise"/>
	<updated>2026-04-05T18:23:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=122</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=122"/>
		<updated>2017-03-02T21:21:38Z</updated>

		<summary type="html">&lt;p&gt;Elise: Add examples of hashlimit translation to nft&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Flow tables ==&lt;br /&gt;
&lt;br /&gt;
Since Linux Kernel 4.3 and nft v0.6 nftables supports flow tables.&lt;br /&gt;
&lt;br /&gt;
Flow tables provides a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables, however, you can use any selector, one or many through [[concatenations]].&lt;br /&gt;
&lt;br /&gt;
== Using flow tables ==&lt;br /&gt;
&lt;br /&gt;
The following commands create a table named &#039;&#039;filter&#039;&#039;, a chain named &#039;&#039;input&#039;&#039; which hooks incoming traffic and a rule that uses a flow table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add chain filter input {type filter hook input priority 0\;}&lt;br /&gt;
% nft add rule filter input tcp dport 22 ct state new flow table ssh-ftable { ip saddr limit rate 10/second } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example we create a rule to match &#039;&#039;new&#039;&#039;  &#039;&#039;ssh&#039;&#039; (port 22) connections, which uses a flow table named &#039;&#039;ssh-ftable&#039;&#039; to limit the traffic rate to 10 packets per second for each source IP address. The available time units on limits are: &#039;&#039;second&#039;&#039;, &#039;&#039;minute&#039;&#039;, &#039;&#039;hour&#039;&#039;, &#039;&#039;day&#039;&#039; and &#039;&#039;week&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You can also use [[concatenations]] to build selectors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter input flow table cnt-ftable { iif . ip saddr . tcp dport timeout 60s counter }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule counts incoming packets based on the tuple &#039;&#039;(input interface index, IP source address, TCP destination port)&#039;&#039;, the counters are dropped after 60 seconds without update.&lt;br /&gt;
&lt;br /&gt;
== Listing flow tables ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the flow table use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list flow table filter cnt-ftable&lt;br /&gt;
table ip filter {&lt;br /&gt;
	flow table cnt-ftable {&lt;br /&gt;
		type iface_index . ipv4_addr . inet_service&lt;br /&gt;
		flags timeout&lt;br /&gt;
		elements = { &amp;quot;wlan1&amp;quot; . 64.62.190.36 . 55000 expires 38s : counter packets 2 bytes 220, &amp;quot;wlan1&amp;quot; . 83.98.201.47 . 35460 expires 39s : counter packets 10 bytes 5988, &amp;quot;wlan1&amp;quot; . 172.217.7.142 . 43254 expires 46s : counter packets 1 bytes 98}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Doing iptables hashlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Flow tables replace iptables hashlimit in nft. You can use the tool &#039;&#039;&#039;iptables-translate&#039;&#039;&#039; to see how to translate hashlimit rules, currently available in the [https://git.netfilter.org/iptables/ iptables git tree] and expected in the next official release, current release is v1.6.1.&lt;br /&gt;
&lt;br /&gt;
Almost all hashlimit options are available in nft, starting with --hashlimit-mode, it is replaced by the selector in a flow table. All modes are available except no mode, a flow table demands a selector, an iptables rule without hashlimit-mode isn&#039;t supported in nft. A simple rule translation is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables -A INPUT -m tcp -p tcp --dport 80 -m hashlimit --hashlimit-above 200/sec --hashlimit-mode srcip,dstport --hashlimit-name http1 -j DROP&lt;br /&gt;
&lt;br /&gt;
$ nft add rule ip filter input tcp dport 80 flow table http1 { tcp dport . ip saddr limit rate over 200/second} counter drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that a flow table is named, like hashlimit, and using multiple hashlimit-modes is similar to using a concatenation of selectors. Also, --hashlimit-above is translated to &#039;&#039;limit rate over&#039;&#039;, to simulate --hashlimit-upto just omit or replace &#039;&#039;over&#039;&#039; with &#039;&#039;until&#039;&#039; in the rule.&lt;br /&gt;
&lt;br /&gt;
The options --hashlimit-burst and --hashlimit-htable-expire are translated to &#039;&#039;burst&#039;&#039; and &#039;&#039;timeout&#039;&#039; in a flow table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables -A INPUT -m tcp -p tcp --dport 80 -m hashlimit --hashlimit-above 200kb/s --hashlimit-burst 1mb --hashlimit-mode srcip,dstport --hashlimit-name http2 --hashlimit-htable-expire 3000 -j DROP&lt;br /&gt;
&lt;br /&gt;
$ nft add rule ip filter input tcp dport 80 flow table http2 { tcp dport . ip saddr timeout 3s limit rate over 200 kbytes/second burst 1 mbytes} counter drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule shows how &#039;&#039;timeout&#039;&#039; and &#039;&#039;burst&#039;&#039; are used in a flow table, also notice that flow tables, similarly to hashlimit, accepts limiting rates by bytes frequency instead of packets.&lt;br /&gt;
&lt;br /&gt;
Another hashlimit option is to limit the traffic rate on subnets, of IP source or destination addresses, using the options --hashlimit-srcmask and --hashlimit-dstmask. This feature is available in nft by attaching a subnet mask to a flow table selector, attach to &#039;&#039;ip saddr&#039;&#039; for source address and to &#039;&#039;ip daddr&#039;&#039; for destination adress:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables -A INPUT -m tcp -p tcp --dport 80 -m hashlimit --hashlimit-upto 200 --hashlimit-mode srcip --hashlimit-name http3 --hashlimit-srcmask 24 -j DROP&lt;br /&gt;
&lt;br /&gt;
$ nft add rule ip filter input tcp dport 80 flow table http3 { ip saddr and 255.255.255.0 limit rate 200/second} counter drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule will limit packets rate, grouping subnets determined by the first 24 bits of the IP source address, from the incoming packets on port 80.&lt;br /&gt;
&lt;br /&gt;
The remaining options, --hashlimit-htable-max, --hashlimit-htable-size and --hashlimit-htable-gcinterval don&#039;t apply to flow tables.&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Mangling_packet_headers&amp;diff=118</id>
		<title>Mangling packet headers</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Mangling_packet_headers&amp;diff=118"/>
		<updated>2017-02-20T17:43:51Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Mangle packet header fields */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Mangle packet header fields ==&lt;br /&gt;
&lt;br /&gt;
Since nft v0.6 nftables supports stateless payload mangling.&lt;br /&gt;
&lt;br /&gt;
To mangle packet header fields you should create a rule to match the packet, match the desired header field and set a new value to it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table mangle&lt;br /&gt;
% nft add chain mangle forward {type filter hook forward priority 0\;}&lt;br /&gt;
% nft add rule mangle forward tcp dport 8080 tcp dport set 80&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The commands above create a table named &#039;&#039;mangle&#039;&#039;, a chain named &#039;&#039;forward&#039;&#039;, see [[Netfilter hooks]], and a rule to mangle the destination port of packets over TCP from 8080 to 80. Keep in mind the interactions with conntrack, flows with mangled traffic must be untracked.&lt;br /&gt;
&lt;br /&gt;
For more information about packet headers to mangle check manpage nft(8), [[Matching packet header fields]] and [[Quick reference-nftables in 10 minutes]].&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Mangling_packet_headers&amp;diff=117</id>
		<title>Mangling packet headers</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Mangling_packet_headers&amp;diff=117"/>
		<updated>2017-02-17T15:40:57Z</updated>

		<summary type="html">&lt;p&gt;Elise: Create page mangle packet header fields&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Mangle packet header fields ==&lt;br /&gt;
&lt;br /&gt;
Since nft v0.6 nftables supports stateless payload mangling.&lt;br /&gt;
&lt;br /&gt;
To mangle packet header fields you should create a rule to match the packet, match the desired header field and set a new value to it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table mangle&lt;br /&gt;
% nft add chain mangle forward {type filter hook forward priority 0\;}&lt;br /&gt;
% nft add rule mangle forward tcp dport 8080 tcp dport set 80&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The commands above create a table named &#039;&#039;mangle&#039;&#039;, a chain named &#039;&#039;forward&#039;&#039;, see [[Netfilter hooks]], and a rule to mangle the destination port of packets over TCP from 8080 to 80. Keep in mind the interactions with conntrack, flows with mangled traffic must be untracked.&lt;br /&gt;
&lt;br /&gt;
The rule below is another example, it matches packets heading to address &#039;&#039;192.168.1.3&#039;&#039; and modifies their &#039;&#039;Time to Live&#039;&#039; field:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule mangle forward ip daddr 192.168.1.3 ip ttl set 2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information about packet headers to mangle check manpage nft(8), [[Matching packet header fields]] and [[Quick reference-nftables in 10 minutes]].&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=116</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=116"/>
		<updated>2017-02-15T16:32:53Z</updated>

		<summary type="html">&lt;p&gt;Elise: Add links to concatenations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Flow tables ==&lt;br /&gt;
&lt;br /&gt;
Since Linux Kernel 4.3 and nft v0.6 nftables supports flow tables.&lt;br /&gt;
&lt;br /&gt;
Flow tables provides a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables, however, you can use any selector, one or many through [[concatenations]].&lt;br /&gt;
&lt;br /&gt;
== Using flow tables ==&lt;br /&gt;
&lt;br /&gt;
The following commands create a table named &#039;&#039;filter&#039;&#039;, a chain named &#039;&#039;input&#039;&#039; which hooks incoming traffic and a rule that uses a flow table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add chain filter input {type filter hook input priority 0\;}&lt;br /&gt;
% nft add rule filter input tcp dport 22 ct state new flow table ssh-ftable { ip saddr limit rate 10/second } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example we create a rule to match &#039;&#039;new&#039;&#039;  &#039;&#039;ssh&#039;&#039; (port 22) connections, which uses a flow table named &#039;&#039;ssh-ftable&#039;&#039; to limit the traffic rate to 10 packets per second for each source IP address. The available time units on limits are: &#039;&#039;second&#039;&#039;, &#039;&#039;minute&#039;&#039;, &#039;&#039;hour&#039;&#039;, &#039;&#039;day&#039;&#039; and &#039;&#039;week&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You can also use [[concatenations]] to build selectors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter input flow table cnt-ftable { iif . ip saddr . tcp dport timeout 60s counter }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule counts incoming packets based on the tuple &#039;&#039;(input interface index, IP source address, TCP destination port)&#039;&#039;, the counters are dropped after 60 seconds without update.&lt;br /&gt;
&lt;br /&gt;
== Listing flow tables ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the flow table use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list flow table filter cnt-ftable&lt;br /&gt;
table ip filter {&lt;br /&gt;
	flow table cnt-ftable {&lt;br /&gt;
		type iface_index . ipv4_addr . inet_service&lt;br /&gt;
		flags timeout&lt;br /&gt;
		elements = { &amp;quot;wlan1&amp;quot; . 64.62.190.36 . 55000 expires 38s : counter packets 2 bytes 220, &amp;quot;wlan1&amp;quot; . 83.98.201.47 . 35460 expires 39s : counter packets 10 bytes 5988, &amp;quot;wlan1&amp;quot; . 172.217.7.142 . 43254 expires 46s : counter packets 1 bytes 98}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=115</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=115"/>
		<updated>2017-02-15T16:29:39Z</updated>

		<summary type="html">&lt;p&gt;Elise: Create &amp;quot;Flow table&amp;quot; page with usage examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Flow tables ==&lt;br /&gt;
&lt;br /&gt;
Since Linux Kernel 4.3 and nft v0.6 nftables supports flow tables.&lt;br /&gt;
&lt;br /&gt;
Flow tables provides a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables, however, you can use any selector, one or many through concatenations.&lt;br /&gt;
&lt;br /&gt;
== Using flow tables ==&lt;br /&gt;
&lt;br /&gt;
The following commands create a table named &#039;&#039;filter&#039;&#039;, a chain named &#039;&#039;input&#039;&#039; which hooks incoming traffic and a rule that uses a flow table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add chain filter input {type filter hook input priority 0\;}&lt;br /&gt;
% nft add rule filter input tcp dport 22 ct state new flow table ssh-ftable { ip saddr limit rate 10/second } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example we create a rule to match &#039;&#039;new&#039;&#039;  &#039;&#039;ssh&#039;&#039; (port 22) connections, which uses a flow table named &#039;&#039;ssh-ftable&#039;&#039; to limit the traffic rate to 10 packets per second for each source IP address. The available time units on limits are: &#039;&#039;second&#039;&#039;, &#039;&#039;minute&#039;&#039;, &#039;&#039;hour&#039;&#039;, &#039;&#039;day&#039;&#039; and &#039;&#039;week&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You can also use concatenations to build selectors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter input flow table cnt-ftable { iif . ip saddr . tcp dport timeout 60s counter }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule counts incoming packets based on the tuple &#039;&#039;(input interface index, IP source address, TCP destination port)&#039;&#039;, the counters are dropped after 60 seconds without update.&lt;br /&gt;
&lt;br /&gt;
== Listing flow tables ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the flow table use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list flow table filter cnt-ftable&lt;br /&gt;
table ip filter {&lt;br /&gt;
	flow table cnt-ftable {&lt;br /&gt;
		type iface_index . ipv4_addr . inet_service&lt;br /&gt;
		flags timeout&lt;br /&gt;
		elements = { &amp;quot;wlan1&amp;quot; . 64.62.190.36 . 55000 expires 38s : counter packets 2 bytes 220, &amp;quot;wlan1&amp;quot; . 83.98.201.47 . 35460 expires 39s : counter packets 10 bytes 5988, &amp;quot;wlan1&amp;quot; . 172.217.7.142 . 43254 expires 46s : counter packets 1 bytes 98}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=114</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=114"/>
		<updated>2017-02-14T12:57:05Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets specifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set named &#039;&#039;ports&#039;&#039; to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
Multiple flags should be separated by comma:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter flags_set {type ipv4_addr\; flags constant, interval\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;192.168.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;192.168.1.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;performance&#039;&#039; [default]&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=113</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=113"/>
		<updated>2017-02-13T18:15:54Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets specifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set named &#039;&#039;ports&#039;&#039; to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
Multiple flags should be separated by comma:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter flags_set {type ipv4_addr\; flags constant, interval\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;1.1.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;2.2.2.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;performance&#039;&#039; [default]&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=112</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=112"/>
		<updated>2017-02-13T16:32:12Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets specifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set named &#039;&#039;ports&#039;&#039; to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, only one flag can be set at a time, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;1.1.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;2.2.2.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;performance&#039;&#039; [default]&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=111</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=111"/>
		<updated>2017-02-13T16:05:28Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the &#039;&#039;nftables&#039;&#039; HOWTO documentation page. Here you will find documentation on how to build, install, configure and use nftables.&lt;br /&gt;
&lt;br /&gt;
This documentation was initially started by Eric Leblond, known as the [https://home.regit.org/netfilter-en/nftables-quick-howto/ nftables quick HOWTO], and it has been extended and enhanced by Pablo Neira Ayuso.&lt;br /&gt;
&lt;br /&gt;
If you have any suggestion to improve it, please send your comments to Netfilter users mailing list &amp;lt;netfilter@vger.kernel.org&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that this documentation is still under development, so &#039;&#039;&#039;consider this work in progress&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
* [[What is nftables?]]&lt;br /&gt;
* [[Why nftables?]]&lt;br /&gt;
* [[Main differences with iptables]]&lt;br /&gt;
* [[Netfilter hooks]] and integration with existing Netfilter components.&lt;br /&gt;
&lt;br /&gt;
= Getting started =&lt;br /&gt;
&lt;br /&gt;
* [[Building and installing nftables from sources]]&lt;br /&gt;
* Using [[nftables from distributions]]&lt;br /&gt;
* [[Troubleshooting|Troubleshooting and FAQ]]&lt;br /&gt;
* [[Quick reference-nftables in 10 minutes|Quick reference, nftables in 10 minutes]]&lt;br /&gt;
&lt;br /&gt;
= Basic operation =&lt;br /&gt;
&lt;br /&gt;
* [[Configuring tables]]&lt;br /&gt;
* [[Configuring chains]]&lt;br /&gt;
* [[Simple rule management]]&lt;br /&gt;
* [[Atomic rule replacement]]&lt;br /&gt;
* [[Error reporting from the command line]]&lt;br /&gt;
* [[Building rules through expressions]]&lt;br /&gt;
* [[Operations at ruleset level]]&lt;br /&gt;
* [[Monitoring ruleset updates]]&lt;br /&gt;
* [[Scripting]]&lt;br /&gt;
* [[Ruleset debug/tracing]]&lt;br /&gt;
* [[Moving from iptables to nftables]]&lt;br /&gt;
&lt;br /&gt;
= Supported selectors for packet matching =&lt;br /&gt;
&lt;br /&gt;
* [[Matching packet header fields]]&lt;br /&gt;
* [[Matching packet metainformation]]&lt;br /&gt;
* [[Matching connection tracking stateful metainformation]]&lt;br /&gt;
* [[Rate limiting matchings]]&lt;br /&gt;
* [[Routing information]]&lt;br /&gt;
&lt;br /&gt;
= Possible actions on packets =&lt;br /&gt;
&lt;br /&gt;
* [[Accepting and dropping packets]]&lt;br /&gt;
* [[Jumping to chain]]&lt;br /&gt;
* [[Rejecting traffic]]&lt;br /&gt;
* [[Logging traffic]]&lt;br /&gt;
* [[Performing Network Address Translation (NAT)]]&lt;br /&gt;
* [[Setting packet metainformation]]&lt;br /&gt;
* [[Queueing to userspace]]&lt;br /&gt;
* [[Duplicating packets]]&lt;br /&gt;
* [[Mangle packet header fields]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
&lt;br /&gt;
Note that, unlike &#039;&#039;iptables&#039;&#039;, you can perform several actions in one single rule.&lt;br /&gt;
&lt;br /&gt;
= Advanced data structures for performance packet classification =&lt;br /&gt;
&lt;br /&gt;
You will have to redesign your rule-set to benefit from these new nice features:&lt;br /&gt;
&lt;br /&gt;
* [[Sets]]&lt;br /&gt;
* [[Dictionaries]]&lt;br /&gt;
* [[Intervals]]&lt;br /&gt;
* [[Maps]]&lt;br /&gt;
* [[Concatenations]]&lt;br /&gt;
* [[Flow tables]]&lt;br /&gt;
* [[Updating sets from the packet path]]&lt;br /&gt;
* [[Element timeouts]]&lt;br /&gt;
* [[Math operations]]&lt;br /&gt;
* [[Stateful objects]]&lt;br /&gt;
&lt;br /&gt;
If you are already using [[ipset]] in your &#039;&#039;iptables&#039;&#039; rule-set, that transition may be a bit more simple to you.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
* [[Simple ruleset for a workstation]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
&lt;br /&gt;
= Development progress =&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[Supported features compared to xtables|Supported features compared to {ip,ip6,eb,arp}tables]]&lt;br /&gt;
* [[List of available translations via iptables-translate tool]]&lt;br /&gt;
&lt;br /&gt;
= Videos =&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=FXTRRwXi3b4 Getting a grasp of nftables], thanks to [https://www.nluug.nl/index-en.html NLUUG association] for recording this.&lt;br /&gt;
&lt;br /&gt;
= Thanks =&lt;br /&gt;
&lt;br /&gt;
To the NLnet foundation for initial sponsorship of this HOWTO:&lt;br /&gt;
&lt;br /&gt;
[https://nlnet.nl https://nlnet.nl/image/logo.gif]&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=110</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=110"/>
		<updated>2017-02-13T16:04:45Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Advanced data structures for performance packet classification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the &#039;&#039;nftables&#039;&#039; HOWTO documentation page. Here you will find documentation on how to build, install, configure and use nftables.&lt;br /&gt;
&lt;br /&gt;
This documentation was initially started by Eric Leblond, known as the [https://home.regit.org/netfilter-en/nftables-quick-howto/ nftables quick HOWTO], and it has been extended and enhanced by Pablo Neira Ayuso.&lt;br /&gt;
&lt;br /&gt;
If you have any suggestion to improve it, please send your comments to Netfilter users mailing list &amp;lt;netfilter@vger.kernel.org&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that this documentation is still under development, so &#039;&#039;&#039;consider this work in progress&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
* [[What is nftables?]]&lt;br /&gt;
* [[Why nftables?]]&lt;br /&gt;
* [[Main differences with iptables]]&lt;br /&gt;
* [[Netfilter hooks]] and integration with existing Netfilter components.&lt;br /&gt;
&lt;br /&gt;
= Getting started =&lt;br /&gt;
&lt;br /&gt;
* [[Building and installing nftables from sources]]&lt;br /&gt;
* Using [[nftables from distributions]]&lt;br /&gt;
* [[Troubleshooting|Troubleshooting and FAQ]]&lt;br /&gt;
* [[Quick reference-nftables in 10 minutes|Quick reference, nftables in 10 minutes]]&lt;br /&gt;
&lt;br /&gt;
= Basic operation =&lt;br /&gt;
&lt;br /&gt;
* [[Configuring tables]]&lt;br /&gt;
* [[Configuring chains]]&lt;br /&gt;
* [[Simple rule management]]&lt;br /&gt;
* [[Atomic rule replacement]]&lt;br /&gt;
* [[Error reporting from the command line]]&lt;br /&gt;
* [[Building rules through expressions]]&lt;br /&gt;
* [[Operations at ruleset level]]&lt;br /&gt;
* [[Monitoring ruleset updates]]&lt;br /&gt;
* [[Scripting]]&lt;br /&gt;
* [[Ruleset debug/tracing]]&lt;br /&gt;
* [[Moving from iptables to nftables]]&lt;br /&gt;
&lt;br /&gt;
= Supported selectors for packet matching =&lt;br /&gt;
&lt;br /&gt;
* [[Matching packet header fields]]&lt;br /&gt;
* [[Matching packet metainformation]]&lt;br /&gt;
* [[Matching connection tracking stateful metainformation]]&lt;br /&gt;
* [[Rate limiting matchings]]&lt;br /&gt;
* [[Routing information]]&lt;br /&gt;
&lt;br /&gt;
= Possible actions on packets =&lt;br /&gt;
&lt;br /&gt;
* [[Accepting and dropping packets]]&lt;br /&gt;
* [[Jumping to chain]]&lt;br /&gt;
* [[Rejecting traffic]]&lt;br /&gt;
* [[Logging traffic]]&lt;br /&gt;
* [[Performing Network Address Translation (NAT)]]&lt;br /&gt;
* [[Setting packet metainformation]]&lt;br /&gt;
* [[Queueing to userspace]]&lt;br /&gt;
* [[Duplicating packets]]&lt;br /&gt;
* [[Mangle packet header fields]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
&lt;br /&gt;
Note that, unlike &#039;&#039;iptables&#039;&#039;, you can perform several actions in one single rule.&lt;br /&gt;
&lt;br /&gt;
= Advanced data structures for performance packet classification =&lt;br /&gt;
&lt;br /&gt;
You will have to redesign your rule-set to benefit from these new nice features:&lt;br /&gt;
&lt;br /&gt;
* [[Sets]]&lt;br /&gt;
* [[Dictionaries]]&lt;br /&gt;
* [[Intervals]]&lt;br /&gt;
* [[Maps]]&lt;br /&gt;
* [[Concatenations]]&lt;br /&gt;
* [[Flow tables]]&lt;br /&gt;
* [[Updating sets from the packet path]]&lt;br /&gt;
* [[Element timeouts]]&lt;br /&gt;
* [[Math operations]]&lt;br /&gt;
* [[Stateful objects]]&lt;br /&gt;
&lt;br /&gt;
If you are already using [[ipset]] in your &#039;&#039;iptables&#039;&#039; rule-set, that transition may be a bit more simple to you.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
* [[Simple ruleset for a workstation]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Stateful objects usage]]&lt;br /&gt;
&lt;br /&gt;
= Development progress =&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[Supported features compared to xtables|Supported features compared to {ip,ip6,eb,arp}tables]]&lt;br /&gt;
* [[List of available translations via iptables-translate tool]]&lt;br /&gt;
&lt;br /&gt;
= Videos =&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=FXTRRwXi3b4 Getting a grasp of nftables], thanks to [https://www.nluug.nl/index-en.html NLUUG association] for recording this.&lt;br /&gt;
&lt;br /&gt;
= Thanks =&lt;br /&gt;
&lt;br /&gt;
To the NLnet foundation for initial sponsorship of this HOWTO:&lt;br /&gt;
&lt;br /&gt;
[https://nlnet.nl https://nlnet.nl/image/logo.gif]&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects_usage&amp;diff=109</id>
		<title>Stateful objects usage</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects_usage&amp;diff=109"/>
		<updated>2017-02-13T16:03:17Z</updated>

		<summary type="html">&lt;p&gt;Elise: Elise moved page Stateful objects usage to Stateful objects: This tittle better fit the naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Stateful objects]]&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=108</id>
		<title>Stateful objects</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=108"/>
		<updated>2017-02-13T16:03:16Z</updated>

		<summary type="html">&lt;p&gt;Elise: Elise moved page Stateful objects usage to Stateful objects: This tittle better fit the naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since Linux Kernel 4.10 and nft v0.8 nftables supports stateful objects.&lt;br /&gt;
&lt;br /&gt;
Stateful objects group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables and have a unique name, defined by the user.&lt;br /&gt;
&lt;br /&gt;
= Creating stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can create a counter with the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a table named &#039;&#039;filter&#039;&#039;, then a counter named &#039;&#039;https-traffic&#039;&#039; and attaches it to &#039;&#039;filter&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Creating a quota is similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add quota filter https-quota 25 mbytes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A quota named &#039;&#039;https-quota&#039;&#039; is attached to the table &#039;&#039;filter&#039;&#039;, notice that you must specify the quota&#039;s size on creation.&lt;br /&gt;
&lt;br /&gt;
= Referencing stateful objects in rules =&lt;br /&gt;
&lt;br /&gt;
Stateful objects are referenced in rules by their names, the simplest way is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter output { type filter hook output priority 0 \; }&lt;br /&gt;
% nft add rule filter output tcp dport https counter name https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a chain named &#039;&#039;output&#039;&#039; in the table &#039;&#039;filter&#039;&#039;, then a rule to counter the &#039;&#039;https&#039;&#039; packets generated by your machine and display them in the counter &#039;&#039;https-traffic&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
They can also be used with maps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output counter name tcp dport map { \&lt;br /&gt;
          https : &amp;quot;https-traffic&amp;quot;, \&lt;br /&gt;
          80 : &amp;quot;http-traffic&amp;quot;, \&lt;br /&gt;
          25 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          50 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          107 : &amp;quot;foo-counter&amp;quot; \&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, dynamic maps can be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add map filter ports { type inet_service : quota \; }&lt;br /&gt;
% nft add rule filter output quota name tcp dport map @ports&lt;br /&gt;
% nft add quota filter http-quota over 25 mbytes&lt;br /&gt;
% nft add quota filter ssh-quota 10 kbytes&lt;br /&gt;
% nft add element filter ports { 80 : &amp;quot;http-quota&amp;quot; }&lt;br /&gt;
% nft add element filter ports { 22 : &amp;quot;ssh-quota&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Listing stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can list the stateful information of objects individually via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, it&#039;s possible to list all stateful objects of the same type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list quotas&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And list all stateful objects of a type in a table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counters table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Reseting stateful objects =&lt;br /&gt;
&lt;br /&gt;
Reseting an object will atomically dump and reset its content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes used 217 kbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
% nft list quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other usages are similar to the command list, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset counters&lt;br /&gt;
% nft reset quotas table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=107</id>
		<title>Stateful objects</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=107"/>
		<updated>2017-02-11T12:38:01Z</updated>

		<summary type="html">&lt;p&gt;Elise: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since Linux Kernel 4.10 and nft v0.8 nftables supports stateful objects.&lt;br /&gt;
&lt;br /&gt;
Stateful objects group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables and have a unique name, defined by the user.&lt;br /&gt;
&lt;br /&gt;
= Creating stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can create a counter with the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a table named &#039;&#039;filter&#039;&#039;, then a counter named &#039;&#039;https-traffic&#039;&#039; and attaches it to &#039;&#039;filter&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Creating a quota is similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add quota filter https-quota 25 mbytes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A quota named &#039;&#039;https-quota&#039;&#039; is attached to the table &#039;&#039;filter&#039;&#039;, notice that you must specify the quota&#039;s size on creation.&lt;br /&gt;
&lt;br /&gt;
= Referencing stateful objects in rules =&lt;br /&gt;
&lt;br /&gt;
Stateful objects are referenced in rules by their names, the simplest way is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter output { type filter hook output priority 0 \; }&lt;br /&gt;
% nft add rule filter output tcp dport https counter name https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a chain named &#039;&#039;output&#039;&#039; in the table &#039;&#039;filter&#039;&#039;, then a rule to counter the &#039;&#039;https&#039;&#039; packets generated by your machine and display them in the counter &#039;&#039;https-traffic&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
They can also be used with maps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output counter name tcp dport map { \&lt;br /&gt;
          https : &amp;quot;https-traffic&amp;quot;, \&lt;br /&gt;
          80 : &amp;quot;http-traffic&amp;quot;, \&lt;br /&gt;
          25 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          50 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          107 : &amp;quot;foo-counter&amp;quot; \&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, dynamic maps can be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add map filter ports { type inet_service : quota \; }&lt;br /&gt;
% nft add rule filter output quota name tcp dport map @ports&lt;br /&gt;
% nft add quota filter http-quota over 25 mbytes&lt;br /&gt;
% nft add quota filter ssh-quota 10 kbytes&lt;br /&gt;
% nft add element filter ports { 80 : &amp;quot;http-quota&amp;quot; }&lt;br /&gt;
% nft add element filter ports { 22 : &amp;quot;ssh-quota&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Listing stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can list the stateful information of objects individually via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, it&#039;s possible to list all stateful objects of the same type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list quotas&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And list all stateful objects of a type in a table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counters table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Reseting stateful objects =&lt;br /&gt;
&lt;br /&gt;
Reseting an object will atomically dump and reset its content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes used 217 kbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
% nft list quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other usages are similar to the command list, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset counters&lt;br /&gt;
% nft reset quotas table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=106</id>
		<title>Stateful objects</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=106"/>
		<updated>2017-02-11T12:31:47Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Reseting stateful objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Stateful objects group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables and have a unique name, defined by the user.&lt;br /&gt;
&lt;br /&gt;
= Creating stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can create a counter with the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a table named &#039;&#039;filter&#039;&#039;, then a counter named &#039;&#039;https-traffic&#039;&#039; and attaches it to &#039;&#039;filter&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Creating a quota is similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add quota filter https-quota 25 mbytes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A quota named &#039;&#039;https-quota&#039;&#039; is attached to the table &#039;&#039;filter&#039;&#039;, notice that you must specify the quota&#039;s size on creation.&lt;br /&gt;
&lt;br /&gt;
= Referencing stateful objects in rules =&lt;br /&gt;
&lt;br /&gt;
Stateful objects are referenced in rules by their names, the simplest way is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter output { type filter hook output priority 0 \; }&lt;br /&gt;
% nft add rule filter output tcp dport https counter name https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a chain named &#039;&#039;output&#039;&#039; in the table &#039;&#039;filter&#039;&#039;, then a rule to counter the &#039;&#039;https&#039;&#039; packets generated by your machine and display them in the counter &#039;&#039;https-traffic&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
They can also be used with maps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output counter name tcp dport map { \&lt;br /&gt;
          https : &amp;quot;https-traffic&amp;quot;, \&lt;br /&gt;
          80 : &amp;quot;http-traffic&amp;quot;, \&lt;br /&gt;
          25 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          50 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          107 : &amp;quot;foo-counter&amp;quot; \&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, dynamic maps can be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add map filter ports { type inet_service : quota \; }&lt;br /&gt;
% nft add rule filter output quota name tcp dport map @ports&lt;br /&gt;
% nft add quota filter http-quota over 25 mbytes&lt;br /&gt;
% nft add quota filter ssh-quota 10 kbytes&lt;br /&gt;
% nft add element filter ports { 80 : &amp;quot;http-quota&amp;quot; }&lt;br /&gt;
% nft add element filter ports { 22 : &amp;quot;ssh-quota&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Listing stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can list the stateful information of objects individually via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, it&#039;s possible to list all stateful objects of the same type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list quotas&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And list all stateful objects of a type in a table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counters table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Reseting stateful objects =&lt;br /&gt;
&lt;br /&gt;
Reseting an object will list its content and set it to 0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes used 217 kbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
% nft list quota filter https-quota&lt;br /&gt;
table ip filter {&lt;br /&gt;
	quota https-quota {&lt;br /&gt;
		25 mbytes&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other usages are similar to the command list, e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset counters&lt;br /&gt;
% nft reset quotas table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=105</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=105"/>
		<updated>2017-02-09T17:18:31Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets specifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, only one flag can be set at a time, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;dv&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;hv&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt;mv&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;1.1.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;2.2.2.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
** &#039;&#039;performance&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=104</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=104"/>
		<updated>2017-02-09T16:53:09Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;small&amp;gt;1&amp;lt;/small&amp;gt;dv&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;hv&amp;lt;small&amp;gt;3&amp;lt;/small&amp;gt;mv&amp;lt;small&amp;gt;4&amp;lt;/small&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, only one flag can be set at a time, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;small&amp;gt;1&amp;lt;/small&amp;gt;dv&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;hv&amp;lt;small&amp;gt;3&amp;lt;/small&amp;gt;mv&amp;lt;small&amp;gt;4&amp;lt;/small&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;1.1.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;2.2.2.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
** &#039;&#039;performance&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=103</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=103"/>
		<updated>2017-02-09T16:52:18Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Named sets specifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The supported data types currently are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
* &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
* &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
* &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
* &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
* &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
Sets specifications are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039;, is obrigatory and determines the data type of the set elements. Supported data types currently are:&lt;br /&gt;
** &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
** &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
** &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
** &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
** &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
** &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;timeout&#039;&#039;&#039;, it determines how long an element stays in the set. The time string respects the format: &#039;&#039;&amp;quot;v&amp;lt;small&amp;gt;1&amp;lt;/small&amp;gt;dv&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;hv&amp;lt;small&amp;gt;3&amp;lt;/small&amp;gt;mv&amp;lt;small&amp;gt;4&amp;lt;/small&amp;gt;s&amp;quot;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add set filter ports {type inet_service \; timeout 3h45s \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These commands create a table named &#039;&#039;filter&#039;&#039; and add a set to it, where elements are deleted after 3 hours and 45 seconds of being added.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;flags&#039;&#039;&#039;, only one flag can be set at a time, the available flags are:&lt;br /&gt;
** &#039;&#039;constant&#039;&#039; - set content may not change while bound&lt;br /&gt;
** &#039;&#039;interval&#039;&#039; - set contains intervals&lt;br /&gt;
** &#039;&#039;timeout&#039;&#039; - elements can be added with a timeout&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;gc-interval&#039;&#039;&#039;, stands for garbage collection interval, can only be used if &#039;&#039;timeout&#039;&#039; or &#039;&#039;flags timeout&#039;&#039; are active. The interval follows the same format of &#039;&#039;timeouts&#039;&#039; time string &#039;&#039;&amp;quot;v&amp;lt;small&amp;gt;1&amp;lt;/small&amp;gt;dv&amp;lt;small&amp;gt;2&amp;lt;/small&amp;gt;hv&amp;lt;small&amp;gt;3&amp;lt;/small&amp;gt;mv&amp;lt;small&amp;gt;4&amp;lt;/small&amp;gt;s&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;elements&#039;&#039;&#039;, initialize the set with some elements in it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter daddrs {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command creates a set name &#039;&#039;daddrs&#039;&#039; with elements &#039;&#039;1.1.1.1&#039;&#039;, which stays in it for 10s, and &#039;&#039;2.2.2.2&#039;&#039;, which stays for 30s.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039;, limits the maximum number of elements of the set. To create a set with maximum 2 elements type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter saddrs {type ipv4_addr \; size 2 \;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;policy&#039;&#039;&#039;, determines set selection policy. Available values are:&lt;br /&gt;
** &#039;&#039;memory&#039;&#039;&lt;br /&gt;
** &#039;&#039;performance&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=102</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Sets&amp;diff=102"/>
		<updated>2017-02-09T16:27:58Z</updated>

		<summary type="html">&lt;p&gt;Elise: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;nftables&#039;&#039; comes with a built-in generic set infrastructure that allows you to use &#039;&#039;&#039;any&#039;&#039;&#039; supported selector to build sets. This infrastructure makes possible the representation of [[dictionaries]] and [[maps]].&lt;br /&gt;
&lt;br /&gt;
The set elements are internally represented using performance data structures such as hashtables and red-black trees.&lt;br /&gt;
&lt;br /&gt;
= Anonymous sets =&lt;br /&gt;
&lt;br /&gt;
Anonymous sets are those that are:&lt;br /&gt;
&lt;br /&gt;
* Bound to a rule, if the rule is removed, that set is released too.&lt;br /&gt;
* They have no specific name, the kernel internally allocates an identifier.&lt;br /&gt;
* They cannot be updated. So you cannot add and delete elements from it once it is bound to a rule.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to create a simple set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output tcp dport { 22, 23 } counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule above catches all traffic going to TCP ports 22 and 23, in case of matching the counters are updated.&lt;br /&gt;
&lt;br /&gt;
= Named sets =&lt;br /&gt;
&lt;br /&gt;
You can create the named sets with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add set filter blackhole { type ipv4_addr\;}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;blackhole&#039;&#039; is the name of the set in this case. The &#039;&#039;type&#039;&#039; option indicates the data type that this set stores, which is an IPv4 address in the case. Current maximum name length is 16 characters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add element filter blackhole { 192.168.3.4 }&lt;br /&gt;
% nft add element filter blackhole { 192.168.1.4, 192.168.1.5 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can use it from the rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip input ip saddr @blackhole drop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The supported data types currently are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;ipv4_addr&#039;&#039;: IPv4 address&lt;br /&gt;
* &#039;&#039;ipv6_addr&#039;&#039;: IPv6 address.&lt;br /&gt;
* &#039;&#039;ether_addr&#039;&#039;: Ethernet address.&lt;br /&gt;
* &#039;&#039;inet_proto&#039;&#039;: Inet protocol type.&lt;br /&gt;
* &#039;&#039;inet_service&#039;&#039;: Internet service (read tcp port for example)&lt;br /&gt;
* &#039;&#039;mark&#039;&#039;: Mark type.&lt;br /&gt;
&lt;br /&gt;
Named sets can be updated anytime, so you can add and delete element from them.&lt;br /&gt;
&lt;br /&gt;
Eric Leblond in his [https://home.regit.org/2014/01/why-you-will-love-nftables/ Why you will love nftables] article shows a very simple example to compare iptables with nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip6tables -A INPUT -p tcp -m multiport --dports 23,80,443 -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which can be expressed in &#039;&#039;nftables&#039;&#039; with a couple of rules that provide a set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip6 filter input tcp dport {telnet, http, https} accept&lt;br /&gt;
% nft add rule ip6 filter input icmpv6 type { nd-neighbor-solicit, echo-request, nd-router-advert, nd-neighbor-advert } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Named sets specifications =&lt;br /&gt;
&lt;br /&gt;
= Listing named sets =&lt;br /&gt;
&lt;br /&gt;
You can list the content of a named set via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set filter myset&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=101</id>
		<title>Stateful objects</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=101"/>
		<updated>2017-02-08T15:19:24Z</updated>

		<summary type="html">&lt;p&gt;Elise: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Stateful objects group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables and have a unique name, defined by the user.&lt;br /&gt;
&lt;br /&gt;
= Creating stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can create a counter with the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table filter&lt;br /&gt;
% nft add counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a table named &#039;&#039;filter&#039;&#039;, then a counter named &#039;&#039;https-traffic&#039;&#039; and attaches it to &#039;&#039;filter&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Creating a quota is similar:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add quota filter https-quota 25 mbytes&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A quota named &#039;&#039;https-quota&#039;&#039; is attached to the table &#039;&#039;filter&#039;&#039;, notice that you must specify the quota&#039;s size on creation.&lt;br /&gt;
&lt;br /&gt;
= Referencing stateful objects in rules =&lt;br /&gt;
&lt;br /&gt;
Stateful objects are referenced in rules by their names, the simplest way is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter output { type filter hook output priority 0 \; }&lt;br /&gt;
% nft add rule filter output tcp dport https counter name https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These rules create a chain named &#039;&#039;output&#039;&#039; in the table &#039;&#039;filter&#039;&#039;, then a rule to counter the &#039;&#039;https&#039;&#039; packets generated by your machine and display them in the counter &#039;&#039;https-traffic&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
They can also be used with maps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule filter output counter name tcp dport map { \&lt;br /&gt;
          https : &amp;quot;https-traffic&amp;quot;, \&lt;br /&gt;
          80 : &amp;quot;http-traffic&amp;quot;, \&lt;br /&gt;
          25 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          50 : &amp;quot;foo-counter&amp;quot;, \&lt;br /&gt;
          107 : &amp;quot;foo-counter&amp;quot; \&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, dynamic maps can be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add map filter ports { type inet_service : quota \; }&lt;br /&gt;
% nft add rule filter output quota name tcp dport map @ports&lt;br /&gt;
% nft add quota filter http-quota over 25 mbytes&lt;br /&gt;
% nft add quota filter ssh-quota 10 kbytes&lt;br /&gt;
% nft add element filter ports { 80 : &amp;quot;http-quota&amp;quot; }&lt;br /&gt;
% nft add element filter ports { 22 : &amp;quot;ssh-quota&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Listing stateful objects =&lt;br /&gt;
&lt;br /&gt;
You can list the stateful information of objects individually via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counter filter https-traffic&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, it&#039;s possible to list all stateful objects of the same type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list quotas&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And list all stateful objects of a type in a table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list counters table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Reseting stateful objects =&lt;br /&gt;
&lt;br /&gt;
Reseting an object will list its content and set it to 0. The usage is similar to listing objects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft reset quota filter http-quota&lt;br /&gt;
% nft reset counters&lt;br /&gt;
% nft reset quotas table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=100</id>
		<title>Stateful objects</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Stateful_objects&amp;diff=100"/>
		<updated>2017-02-08T13:55:47Z</updated>

		<summary type="html">&lt;p&gt;Elise: Created page with &amp;quot;Since v0.7 nftables support stateful objects, which group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since v0.7 nftables support stateful objects, which group stateful information of rules, the supported types are: counters and quotas. Stateful objects are attached to tables and have a unique name, defined by the user.&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=99</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=99"/>
		<updated>2017-02-08T13:53:52Z</updated>

		<summary type="html">&lt;p&gt;Elise: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the &#039;&#039;nftables&#039;&#039; HOWTO documentation page. Here you will find documentation on how to build, install, configure and use nftables.&lt;br /&gt;
&lt;br /&gt;
This documentation was initially started by Eric Leblond, known as the [https://home.regit.org/netfilter-en/nftables-quick-howto/ nftables quick HOWTO], and it has been extended and enhanced by Pablo Neira Ayuso.&lt;br /&gt;
&lt;br /&gt;
If you have any suggestion to improve it, please send your comments to Netfilter users mailing list &amp;lt;netfilter@vger.kernel.org&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that this documentation is still under development, so &#039;&#039;&#039;consider this work in progress&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
* [[What is nftables?]]&lt;br /&gt;
* [[Why nftables?]]&lt;br /&gt;
* [[Main differences with iptables]]&lt;br /&gt;
* [[Netfilter hooks]] and integration with existing Netfilter components.&lt;br /&gt;
&lt;br /&gt;
= Getting started =&lt;br /&gt;
&lt;br /&gt;
* [[Building and installing nftables from sources]]&lt;br /&gt;
* Using [[nftables from distributions]]&lt;br /&gt;
* [[Troubleshooting|Troubleshooting and FAQ]]&lt;br /&gt;
* [[Quick reference-nftables in 10 minutes|Quick reference, nftables in 10 minutes]]&lt;br /&gt;
&lt;br /&gt;
= Basic operation =&lt;br /&gt;
&lt;br /&gt;
* [[Configuring tables]]&lt;br /&gt;
* [[Configuring chains]]&lt;br /&gt;
* [[Simple rule management]]&lt;br /&gt;
* [[Atomic rule replacement]]&lt;br /&gt;
* [[Error reporting from the command line]]&lt;br /&gt;
* [[Building rules through expressions]]&lt;br /&gt;
* [[Operations at ruleset level]]&lt;br /&gt;
* [[Monitoring ruleset updates]]&lt;br /&gt;
* [[Scripting]]&lt;br /&gt;
* [[Ruleset debug/tracing]]&lt;br /&gt;
* [[Moving from iptables to nftables]]&lt;br /&gt;
&lt;br /&gt;
= Supported selectors for packet matching =&lt;br /&gt;
&lt;br /&gt;
* [[Matching packet header fields]]&lt;br /&gt;
* [[Matching packet metainformation]]&lt;br /&gt;
* [[Matching connection tracking stateful metainformation]]&lt;br /&gt;
* [[Rate limiting matchings]]&lt;br /&gt;
* [[Routing information]]&lt;br /&gt;
&lt;br /&gt;
= Possible actions on packets =&lt;br /&gt;
&lt;br /&gt;
* [[Accepting and dropping packets]]&lt;br /&gt;
* [[Jumping to chain]]&lt;br /&gt;
* [[Rejecting traffic]]&lt;br /&gt;
* [[Logging traffic]]&lt;br /&gt;
* [[Performing Network Address Translation (NAT)]]&lt;br /&gt;
* [[Setting packet metainformation]]&lt;br /&gt;
* [[Queueing to userspace]]&lt;br /&gt;
* [[Duplicating packets]]&lt;br /&gt;
* [[Mangle packet header fields]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
&lt;br /&gt;
Note that, unlike &#039;&#039;iptables&#039;&#039;, you can perform several actions in one single rule.&lt;br /&gt;
&lt;br /&gt;
= Advanced data structures for performance packet classification =&lt;br /&gt;
&lt;br /&gt;
You will have to redesign your rule-set to benefit from these new nice features:&lt;br /&gt;
&lt;br /&gt;
* [[Sets]]&lt;br /&gt;
* [[Dictionaries]]&lt;br /&gt;
* [[Intervals]]&lt;br /&gt;
* [[Maps]]&lt;br /&gt;
* [[Concatenations]]&lt;br /&gt;
* [[Flow tables]]&lt;br /&gt;
* [[Updating sets from the packet path]]&lt;br /&gt;
* [[Element timeouts]]&lt;br /&gt;
* [[Math operations]]&lt;br /&gt;
&lt;br /&gt;
If you are already using [[ipset]] in your &#039;&#039;iptables&#039;&#039; rule-set, that transition may be a bit more simple to you.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
* [[Simple ruleset for a workstation]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Stateful objects usage]]&lt;br /&gt;
&lt;br /&gt;
= Development progress =&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[Supported features compared to xtables|Supported features compared to {ip,ip6,eb,arp}tables]]&lt;br /&gt;
* [[List of available translations via iptables-translate tool]]&lt;br /&gt;
&lt;br /&gt;
= Videos =&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=FXTRRwXi3b4 Getting a grasp of nftables], thanks to [https://www.nluug.nl/index-en.html NLUUG association] for recording this.&lt;br /&gt;
&lt;br /&gt;
= Thanks =&lt;br /&gt;
&lt;br /&gt;
To the NLnet foundation for initial sponsorship of this HOWTO:&lt;br /&gt;
&lt;br /&gt;
[https://nlnet.nl https://nlnet.nl/image/logo.gif]&lt;/div&gt;</summary>
		<author><name>Elise</name></author>
	</entry>
</feed>