<?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=Admin</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=Admin"/>
	<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php/Special:Contributions/Admin"/>
	<updated>2026-04-05T18:23:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=1152</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=1152"/>
		<updated>2024-10-12T13:47:11Z</updated>

		<summary type="html">&lt;p&gt;Admin: very confusing presentation, remove it&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;
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;
&lt;br /&gt;
= [[News]] =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
* [[What is nftables?]]&lt;br /&gt;
* [[How to obtain help/support]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Reference =&lt;br /&gt;
* [https://www.netfilter.org/projects/nftables/manpage.html man nft - netfilter website]&lt;br /&gt;
* [https://www.mankier.com/8/nft man nft - mankier.com]&lt;br /&gt;
* [[Quick reference-nftables in 10 minutes|Quick reference, nftables in 10 minutes]]&lt;br /&gt;
* [[Netfilter hooks]] and nftables integration with existing Netfilter components&lt;br /&gt;
* [[nftables families|Understanding nftables families]]&lt;br /&gt;
* [[Data_types|Data types]]&lt;br /&gt;
* [[Connection_Tracking_System|Connection tracking system (conntrack)]], used for stateful firewalling and NAT&lt;br /&gt;
* [[Troubleshooting|Troubleshooting and FAQ]]&lt;br /&gt;
* [[Further_documentation|Additional documentation]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Installing nftables =&lt;br /&gt;
* [[nftables from distributions|Using nftables from distributions]]&lt;br /&gt;
* [[Building and installing nftables from sources]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Upgrading from xtables to nftables =&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[Moving from iptables to nftables]]&lt;br /&gt;
* [[Moving from ipset to nftables]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Basic operation =&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;
* [[Ruleset debug/VM code analysis]]&lt;br /&gt;
* [[Output text modifiers]]&lt;br /&gt;
&lt;br /&gt;
= Expressions: Matching packets =&lt;br /&gt;
* [[Matching packet metainformation]]&lt;br /&gt;
* [[Matching packet headers]]&lt;br /&gt;
* [[Matching connection tracking stateful metainformation]]&lt;br /&gt;
* [[Matching routing information]]&lt;br /&gt;
* [[Rate limiting matchings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Statements: Acting on packet matches =&lt;br /&gt;
* [[Accepting and dropping packets]]&lt;br /&gt;
* [[Rejecting traffic]]&lt;br /&gt;
* [[Jumping to chain]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Logging traffic]]&lt;br /&gt;
* [[Performing Network Address Translation (NAT)]]&lt;br /&gt;
* [[Setting packet metainformation]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&lt;br /&gt;
* [[Mangling packet headers]] (including stateless NAT)&lt;br /&gt;
* [[Duplicating packets]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Queueing to userspace]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Advanced data structures for performance packet classification =&lt;br /&gt;
* [[Intervals]]&lt;br /&gt;
* [[Concatenations]]&lt;br /&gt;
* [[Math operations]]&lt;br /&gt;
* [[Stateful objects]]&lt;br /&gt;
** [[Counters]]&lt;br /&gt;
** [[Quotas]]&lt;br /&gt;
** [[Limits]]&lt;br /&gt;
** [[Connlimits]] (&#039;&#039;ct count&#039;&#039;)&lt;br /&gt;
* Other objects&lt;br /&gt;
** [[Conntrack helpers]] (&#039;&#039;ct helper&#039;&#039;, Layer 7 ALG)&lt;br /&gt;
** [[Ct_timeout|Conntrack timeout policies]] (&#039;&#039;ct timeout&#039;&#039;)&lt;br /&gt;
** [[Ct_expectation|Conntrack expectations]] (&#039;&#039;ct expectation&#039;&#039;)&lt;br /&gt;
** [[Synproxy]]&lt;br /&gt;
** [[Secmark|Secmarks]]&lt;br /&gt;
* Generic set infrastructure&lt;br /&gt;
** [[Sets]]&lt;br /&gt;
** [[Element timeouts]]&lt;br /&gt;
** [[Updating sets from the packet path]]&lt;br /&gt;
** [[Maps]]&lt;br /&gt;
** [[Verdict_Maps_(vmaps) | Verdict maps]]&lt;br /&gt;
** [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1)&lt;br /&gt;
* [[Flowtables]] (the fastpath network stack bypass)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
* [[Simple ruleset for a workstation]]&lt;br /&gt;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Simple ruleset for a home router]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
&lt;br /&gt;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter mini-workshop (2017)]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop (2018)]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop (2019)]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=GqGGo4svj7s&amp;amp;feature=youtu.be Netdev 0x14 - Netfilter mini-Workshop (2020)] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&lt;br /&gt;
* Article [https://ral-arturo.org/2020/11/22/python-nftables-tutorial.html How to use nftables from python] and git repository [https://github.com/aborrero/python-nftables-tutorial python-nftables-tutorial.git]&lt;br /&gt;
&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=577</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=577"/>
		<updated>2020-11-18T12:43:24Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter mini-workshop (2017)]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop (2018)]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop (2019)]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=GqGGo4svj7s&amp;amp;feature=youtu.be Netdev 0x14 - Netfilter mini-Workshop (2020)] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=576</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=576"/>
		<updated>2020-11-18T12:43:13Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop (2017)]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop (2018)]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop (2019)]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=GqGGo4svj7s&amp;amp;feature=youtu.be Netdev 0x14 - Netfilter mini-Workshop (2020)] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=575</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=575"/>
		<updated>2020-11-18T12:42:58Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop (2018)]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop (2018)]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop (2019)]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=GqGGo4svj7s&amp;amp;feature=youtu.be Netdev 0x14 - Netfilter mini-Workshop (2020)] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=574</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=574"/>
		<updated>2020-11-18T12:42:23Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=GqGGo4svj7s&amp;amp;feature=youtu.be Netdev 0x14 - Netfilter Workshop] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=573</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=573"/>
		<updated>2020-11-18T12:41:49Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */ fix youtube link&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/watch?v=GqGGo4svj7s - Netdev 0x14 - Netfilter Workshop] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=572</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=572"/>
		<updated>2020-11-18T12:41:25Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* External links */ fix missing ]&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://yewtu.be/watch?v=GqGGo4svj7s - Netdev 0x14 - Netfilter Workshop] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=571</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=571"/>
		<updated>2020-11-18T12:40:51Z</updated>

		<summary type="html">&lt;p&gt;Admin: place update videos&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Watch videos to track updates:&lt;br /&gt;
&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop&lt;br /&gt;
* Watch [https://yewtu.be/watch?v=GqGGo4svj7s - Netdev 0x14 - Netfilter Workshop] &lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=570</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=570"/>
		<updated>2020-11-04T01:06:22Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Enabling nftrace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example assumes you have an existing raw prerouting chain (at priority -300), hence, this is registering a trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -1\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This registers the &#039;&#039;trace_chain&#039;&#039; before the existing &#039;&#039;input&#039;&#039; chain.&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Performing_Network_Address_Translation_(NAT)&amp;diff=569</id>
		<title>Performing Network Address Translation (NAT)</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Performing_Network_Address_Translation_(NAT)&amp;diff=569"/>
		<updated>2020-10-28T22:23:23Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Redirect */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;nat&#039;&#039; chain type allows you to perform NAT. This chain type comes with special semantics:&lt;br /&gt;
&lt;br /&gt;
* The first packet of a flow is used to look up for a matching rule which sets up the NAT binding for this flow. This also manipulates this first packet accordingly.&lt;br /&gt;
* No rule lookup happens for follow up packets in the flow: the NAT engine uses the NAT binding information already set up by the first packet to perform the packet manipulation.&lt;br /&gt;
&lt;br /&gt;
Adding a NAT rule to a filter type chain will result in an error.&lt;br /&gt;
&lt;br /&gt;
= Stateful NAT =&lt;br /&gt;
&lt;br /&gt;
The stateful NAT involves the nf_conntrack kernel engine to match/set packet stateful information and will engage according to the state of connections.&lt;br /&gt;
This is the most common way of performing NAT and the approach we recommend you to follow.&lt;br /&gt;
&lt;br /&gt;
Be aware that &#039;&#039;&#039;with kernel versions before 4.18, you have to register the prerouting/postrouting chains even if you have no rules there&#039;&#039;&#039; since these chain will invoke the NAT engine for the packets coming in the reply direction. The remaining documentation in this article assumes a newer kernel which doesn&#039;t require this inconvenience anymore.&lt;br /&gt;
&lt;br /&gt;
== Source NAT ==&lt;br /&gt;
&lt;br /&gt;
If you want to source NAT the traffic that leaves from your local area network to the Internet, you can create a new table &#039;&#039;nat&#039;&#039; with the postrouting chain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table nat&lt;br /&gt;
% nft &#039;add chain nat postrouting { type nat hook postrouting priority 100 ; }&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add the following rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat postrouting ip saddr 192.168.1.0/24 oif eth0 snat 1.2.3.4&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This matches for all traffic from the 192.168.1.0/24 network to the interface &#039;&#039;eth0&#039;&#039;. The IPv4 address 1.2.3.4 is used as source for the packets that match this rule.&lt;br /&gt;
&lt;br /&gt;
== Destination NAT ==&lt;br /&gt;
&lt;br /&gt;
You need to add the following table and chain configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table nat&lt;br /&gt;
% nft &#039;add chain nat prerouting { type nat hook prerouting priority -100; }&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can add the following rule:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft &#039;add rule nat prerouting iif eth0 tcp dport { 80, 443 } dnat 192.168.1.120&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This redirects the incoming traffic for TCP ports 80 and 443 to 192.168.1.120.&lt;br /&gt;
&lt;br /&gt;
== Masquerading ==&lt;br /&gt;
&lt;br /&gt;
NOTE: &#039;&#039;masquerade&#039;&#039; is available starting with Linux Kernel 3.18.&lt;br /&gt;
&lt;br /&gt;
Masquerade is a special case of SNAT, where the source address is automagically set to the address of the output interface. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat postrouting masquerade&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &#039;&#039;masquerade&#039;&#039; only makes sense from postrouting chain of NAT type.&lt;br /&gt;
&lt;br /&gt;
== Redirect ==&lt;br /&gt;
&lt;br /&gt;
NOTE: &#039;&#039;redirect&#039;&#039; is available starting with Linux Kernel 3.19.&lt;br /&gt;
&lt;br /&gt;
By using redirect, packets will be forwarded to local machine. Is a special case of DNAT where the destination is the current machine.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat prerouting redirect&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example redirects 22/tcp traffic to 2222/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat prerouting tcp dport 22 redirect to 2222&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example redirects outgoing 53/tcp traffic to a local proxy listening on port 10053/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat output tcp dport 853 redirect to 10053&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that: &#039;&#039;redirect&#039;&#039; only makes sense in prerouting and output chains of NAT type.&lt;br /&gt;
&lt;br /&gt;
== NAT flags ==&lt;br /&gt;
&lt;br /&gt;
Since Linux kernel 3.18, you can combine the following flags with your NAT statements:&lt;br /&gt;
&lt;br /&gt;
* random: randomize source port mapping.&lt;br /&gt;
* fully-random: full port randomization.&lt;br /&gt;
* persistent: gives a client the same source-/destination-address for each connection.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule nat postrouting masquerade random,persistent&lt;br /&gt;
% nft add rule nat postrouting ip saddr 192.168.1.0/24 oif eth0 snat 1.2.3.4 fully-random&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inet family NAT ==&lt;br /&gt;
&lt;br /&gt;
Since Linux kernel 5.2, there is support for performing stateful NAT in &#039;&#039;inet&#039;&#039; family chains. Syntax and semantics are equivalent to &#039;&#039;ip&#039;&#039;/&#039;&#039;ip6&#039;&#039; families; the only exception being if IP addresses are specified, a prefix of either &#039;&#039;ip&#039;&#039; or &#039;&#039;ip6&#039;&#039; to clarify the address family is required:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule inet nat prerouting dnat ip to 10.0.0.2&lt;br /&gt;
% nft add rule inet nat prerouting dnat ip6 to feed::c0fe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Incompatibilities ==&lt;br /&gt;
&lt;br /&gt;
You cannot use iptables and nft to perform NAT at the same time before kernel 4.18. So make sure that the &#039;&#039;iptable_nat&#039;&#039; module is unloaded:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% rmmod iptable_nat&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With later kernels, it is possible to use iptables and nftables nat at the same time.&lt;br /&gt;
The nat chains are consulted according to their priorities, the first matching rule&lt;br /&gt;
that adds a nat mapping (dnat, snat, masquerade) is the one that will be used for the connection.&lt;br /&gt;
&lt;br /&gt;
= Stateless NAT =&lt;br /&gt;
&lt;br /&gt;
This type of NAT just modifies each packet according to your rules without any other state/connection tracking.&lt;br /&gt;
&lt;br /&gt;
This is valid for 1:1 mappings and is faster than stateful NAT. However, it&#039;s easy to shoot yourself in the foot.&lt;br /&gt;
If your environment doesn&#039;t require this approach, better stick to stateful NAT.&lt;br /&gt;
&lt;br /&gt;
You have to disable connection tracking for modified packets.&lt;br /&gt;
&lt;br /&gt;
The example below sets IP/port for each packet (also valid in IPv6):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
% nft add rule ip raw prerouting ip protocol tcp ip daddr set 192.168.1.100 tcp dport set 10 notrack&lt;br /&gt;
% nft add rule ip6 raw prerouting ip6 nexthdr tcp ip6 daddr set fe00::1 tcp dport set 10 notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be sure to check our documentation regarding [[Mangle packet header fields | mangling packets]] and [[setting packet connection tracking metainformation]].&lt;br /&gt;
&lt;br /&gt;
To use this feature you require nftables &amp;gt;=0.7 and linux kernel &amp;gt;= 4.9.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
* [[Multiple_NATs_using_nftables_maps | Example: multiple NATs using nftables maps]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=568</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=568"/>
		<updated>2020-10-28T22:16:05Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example assumes you have an existing raw prerouting chain (at priority -300), hence, this is registering a trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -1\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This registers the &#039;&#039;trace_chain&#039;&#039; before the existing &#039;&#039;input&#039;&#039; chain.&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=567</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=567"/>
		<updated>2020-10-28T22:15:49Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example assumes you have an existing raw prerouting chain (at priority -300), hence, this is registering a trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -1\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This register the &#039;&#039;trace_chain&#039;&#039; before the existing &#039;&#039;input&#039;&#039; chain.&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=566</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=566"/>
		<updated>2020-10-28T22:14:36Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Use a chain to enable tracing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example assumes you have an existing raw prerouting chain (at priority -300), hence, this is registering a trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=565</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=565"/>
		<updated>2020-10-28T22:14:00Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Use a chain to enable tracing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming you have an existing raw prerouting chain (at priority -300), you can register this trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=564</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=564"/>
		<updated>2020-10-28T22:13:43Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Use a chain to enable tracing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to go is to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; to enable tracing. If you already have a prerouting chain, then make sure your &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -301\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assuming you have an existing raw prerouting chain (at priority -300), you can register this trace chain right before this chain (at priority -301).&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=563</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=563"/>
		<updated>2020-10-28T21:52:09Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* enabling nftrace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= Enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to go is to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, if you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=562</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=562"/>
		<updated>2020-10-28T21:51:34Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Use a chain to enable tracing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to go is to enable tracing is to add a chain for this purpose.&lt;br /&gt;
&lt;br /&gt;
Register a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, if you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=561</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=561"/>
		<updated>2020-10-28T21:51:10Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Use a chain to enable tracing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to go is to enable tracing is to add a chain.&lt;br /&gt;
&lt;br /&gt;
For this purpose, register a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, if you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=560</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=560"/>
		<updated>2020-10-28T21:46:48Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* enabling nftrace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
= Use a chain to enable tracing =&lt;br /&gt;
&lt;br /&gt;
The recommended way to go is to enable tracing on demand to debug your ruleset.&lt;br /&gt;
&lt;br /&gt;
For this purpose, register a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, if you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=559</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=559"/>
		<updated>2020-10-28T21:42:40Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=558</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=558"/>
		<updated>2020-10-28T21:41:57Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% cat ruleset.nft&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace id uniquely identifies a packet. The trace describes the packet entering the chain initially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:aa:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the packet travel through the ruleset.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=557</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=557"/>
		<updated>2020-10-28T21:38:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= Complete example =&lt;br /&gt;
&lt;br /&gt;
Here is complete example of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% cat ruleset.nft&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:dd:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:dd:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing two different kind of packets at the same monitor session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft filter input tcp dport 10000 nftrace set 1&lt;br /&gt;
% nft filter input icmp type echo-request nftrace set 1&lt;br /&gt;
% nft -nn monitor trace&lt;br /&gt;
trace id e1f5055f ip filter input packet: iif eth0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 ip saddr 192.168.122.1 ip daddr 192.168.122.83 ip tos 0 ip ttl 64 ip id 32315 ip length 84 icmp type echo-request icmp code 0 icmp id 10087 icmp sequence 1&lt;br /&gt;
trace id e1f5055f ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id e1f5055f ip filter input verdict continue&lt;br /&gt;
trace id e1f5055f ip filter input&lt;br /&gt;
trace id 74e47ad2 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 0 ip ttl 64 ip id 49030 ip length 84 icmp type echo-request icmp code 0 icmp id 10095 icmp sequence 1&lt;br /&gt;
trace id 74e47ad2 ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 74e47ad2 ip filter input verdict continue&lt;br /&gt;
trace id 74e47ad2 ip filter input&lt;br /&gt;
trace id 3030de23 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 16 ip ttl 64 ip id 59062 ip length 60 tcp sport 55438 tcp dport 10000 tcp flags == syn tcp window 29200&lt;br /&gt;
trace id 3030de23 ip filter input rule tcp dport 10000 nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 3030de23 ip filter input verdict continue&lt;br /&gt;
trace id 3030de23 ip filter input&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=556</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=556"/>
		<updated>2020-10-28T21:37:46Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* complete example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= complete example =&lt;br /&gt;
&lt;br /&gt;
Here are a couple of complete examples of this debug/tracing mechanism in work. Assuming you have this ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% cat ruleset.nft&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority filter; policy drop;&lt;br /&gt;
                ct state established,related counter packets 2 bytes 292 accept&lt;br /&gt;
                ct state new tcp dport 22 counter packets 0 bytes 0 accept&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
% nft -f ruleset.nft&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, add a chain that enables tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the rule to enable the tracing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Simple tracing test, by pinging one host:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You run on a different terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:dd:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain rule meta nftrace set 1 (verdict continue)&lt;br /&gt;
trace id a95ea7ef ip filter trace_chain verdict continue &lt;br /&gt;
trace id a95ea7ef ip filter trace_chain policy accept &lt;br /&gt;
trace id a95ea7ef ip filter input packet: iif &amp;quot;enp0s25&amp;quot; ether saddr 00:0d:b9:4a:49:3d ether daddr 3c:97:0e:39:dd:20 ip saddr 8.8.8.8 ip daddr 192.168.2.118 ip dscp cs0 ip ecn not-ect ip ttl 115 ip id 0 ip length 84 icmp type echo-reply icmp code net-unreachable icmp id 9253 icmp sequence 1 @th,64,96 24106705117628271805883024640 &lt;br /&gt;
trace id a95ea7ef ip filter input rule ct state established,related counter packets 168 bytes 53513 accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing two different kind of packets at the same monitor session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft filter input tcp dport 10000 nftrace set 1&lt;br /&gt;
% nft filter input icmp type echo-request nftrace set 1&lt;br /&gt;
% nft -nn monitor trace&lt;br /&gt;
trace id e1f5055f ip filter input packet: iif eth0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 ip saddr 192.168.122.1 ip daddr 192.168.122.83 ip tos 0 ip ttl 64 ip id 32315 ip length 84 icmp type echo-request icmp code 0 icmp id 10087 icmp sequence 1&lt;br /&gt;
trace id e1f5055f ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id e1f5055f ip filter input verdict continue&lt;br /&gt;
trace id e1f5055f ip filter input&lt;br /&gt;
trace id 74e47ad2 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 0 ip ttl 64 ip id 49030 ip length 84 icmp type echo-request icmp code 0 icmp id 10095 icmp sequence 1&lt;br /&gt;
trace id 74e47ad2 ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 74e47ad2 ip filter input verdict continue&lt;br /&gt;
trace id 74e47ad2 ip filter input&lt;br /&gt;
trace id 3030de23 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 16 ip ttl 64 ip id 59062 ip length 60 tcp sport 55438 tcp dport 10000 tcp flags == syn tcp window 29200&lt;br /&gt;
trace id 3030de23 ip filter input rule tcp dport 10000 nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 3030de23 ip filter input verdict continue&lt;br /&gt;
trace id 3030de23 ip filter input&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=555</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=555"/>
		<updated>2020-10-28T21:27:24Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* enabling nftrace */ refine&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have a prerouting chain, then make sure the &#039;&#039;trace_chain&#039;&#039; priority comes &#039;&#039;before&#039;&#039; your existing prerouting chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= complete example =&lt;br /&gt;
&lt;br /&gt;
Here are a couple of complete examples of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Simple tracing test:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule inet filter input iif lo counter nftrace set 1 accept&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id 530fa6dd inet filter input packet: iif lo &lt;br /&gt;
trace id 530fa6dd inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
trace id 87a375ea inet filter input packet: iif lo &lt;br /&gt;
trace id 87a375ea inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing two different kind of packets at the same monitor session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft filter input tcp dport 10000 nftrace set 1&lt;br /&gt;
% nft filter input icmp type echo-request nftrace set 1&lt;br /&gt;
% nft -nn monitor trace&lt;br /&gt;
trace id e1f5055f ip filter input packet: iif eth0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 ip saddr 192.168.122.1 ip daddr 192.168.122.83 ip tos 0 ip ttl 64 ip id 32315 ip length 84 icmp type echo-request icmp code 0 icmp id 10087 icmp sequence 1&lt;br /&gt;
trace id e1f5055f ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id e1f5055f ip filter input verdict continue&lt;br /&gt;
trace id e1f5055f ip filter input&lt;br /&gt;
trace id 74e47ad2 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 0 ip ttl 64 ip id 49030 ip length 84 icmp type echo-request icmp code 0 icmp id 10095 icmp sequence 1&lt;br /&gt;
trace id 74e47ad2 ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 74e47ad2 ip filter input verdict continue&lt;br /&gt;
trace id 74e47ad2 ip filter input&lt;br /&gt;
trace id 3030de23 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 16 ip ttl 64 ip id 59062 ip length 60 tcp sport 55438 tcp dport 10000 tcp flags == syn tcp window 29200&lt;br /&gt;
trace id 3030de23 ip filter input rule tcp dport 10000 nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 3030de23 ip filter input verdict continue&lt;br /&gt;
trace id 3030de23 ip filter input&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=554</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=554"/>
		<updated>2020-10-28T21:26:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* enabling nftrace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have more prerouting chains, then select a chain priority that comes &#039;&#039;before&#039;&#039; your existing prerouting chains.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= complete example =&lt;br /&gt;
&lt;br /&gt;
Here are a couple of complete examples of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Simple tracing test:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule inet filter input iif lo counter nftrace set 1 accept&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id 530fa6dd inet filter input packet: iif lo &lt;br /&gt;
trace id 530fa6dd inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
trace id 87a375ea inet filter input packet: iif lo &lt;br /&gt;
trace id 87a375ea inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing two different kind of packets at the same monitor session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft filter input tcp dport 10000 nftrace set 1&lt;br /&gt;
% nft filter input icmp type echo-request nftrace set 1&lt;br /&gt;
% nft -nn monitor trace&lt;br /&gt;
trace id e1f5055f ip filter input packet: iif eth0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 ip saddr 192.168.122.1 ip daddr 192.168.122.83 ip tos 0 ip ttl 64 ip id 32315 ip length 84 icmp type echo-request icmp code 0 icmp id 10087 icmp sequence 1&lt;br /&gt;
trace id e1f5055f ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id e1f5055f ip filter input verdict continue&lt;br /&gt;
trace id e1f5055f ip filter input&lt;br /&gt;
trace id 74e47ad2 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 0 ip ttl 64 ip id 49030 ip length 84 icmp type echo-request icmp code 0 icmp id 10095 icmp sequence 1&lt;br /&gt;
trace id 74e47ad2 ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 74e47ad2 ip filter input verdict continue&lt;br /&gt;
trace id 74e47ad2 ip filter input&lt;br /&gt;
trace id 3030de23 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 16 ip ttl 64 ip id 59062 ip length 60 tcp sport 55438 tcp dport 10000 tcp flags == syn tcp window 29200&lt;br /&gt;
trace id 3030de23 ip filter input rule tcp dport 10000 nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 3030de23 ip filter input verdict continue&lt;br /&gt;
trace id 3030de23 ip filter input&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=553</id>
		<title>Ruleset debug/tracing</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Ruleset_debug/tracing&amp;diff=553"/>
		<updated>2020-10-28T21:25:43Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* enabling nftrace */ extend tracing info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since nftables v0.6 and linux kernel 4.6, ruleset debug/tracing is supported.&lt;br /&gt;
&lt;br /&gt;
This is an equivalent of the old iptables method -J TRACE, but with some great improvements.&lt;br /&gt;
&lt;br /&gt;
The steps to enable debug/tracing is the following:&lt;br /&gt;
* give support in your ruleset for it (set nftrace in any of your rules)&lt;br /&gt;
* monitor the trace events from the nft tool&lt;br /&gt;
&lt;br /&gt;
= enabling nftrace =&lt;br /&gt;
&lt;br /&gt;
To enable nftrace in a packet, use a rule with this statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After all, nftrace is part of the [[Setting packet metainformation|metainformation]] of a packet.&lt;br /&gt;
&lt;br /&gt;
Of course, you may only enable nftrace for a given matching packet.&lt;br /&gt;
In the example below, we only enable nftrace for tcp packets using the loopback interface:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
iif lo ip protocol tcp meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjusting nftrace to only your subset of desired packets is key to properly debug the ruleset, otherwise you may get a lot of debug/tracing information which may be overwhelming.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to enable tracing for your existing ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain filter trace_chain { type filter hook prerouting priority -600\; }&lt;br /&gt;
% nft add rule filter trace_chain meta nftrace set 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is registering a &#039;&#039;trace_chain&#039;&#039; chain at priority -600 which contains a rule to enable tracing. If you already have more prerouting chains, then select a chain priority that comes before your existing chain.&lt;br /&gt;
&lt;br /&gt;
Once you are done with rule tracing, you can just delete this chain to disable it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete chain filter trace_chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= monitoring tracing events =&lt;br /&gt;
&lt;br /&gt;
In nftables, getting the debug/tracing events is a bit different from the iptables world.&lt;br /&gt;
Now, we have an event-based monitor for the kernel to notify the nft tool.&lt;br /&gt;
&lt;br /&gt;
The basic syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each trace event is assigned an &#039;id&#039; for you to easily follow different packets in the same trace session.&lt;br /&gt;
&lt;br /&gt;
= complete example =&lt;br /&gt;
&lt;br /&gt;
Here are a couple of complete examples of this debug/tracing mechanism in work.&lt;br /&gt;
&lt;br /&gt;
Simple tracing test:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule inet filter input iif lo counter nftrace set 1 accept&lt;br /&gt;
% nft monitor trace&lt;br /&gt;
trace id 530fa6dd inet filter input packet: iif lo &lt;br /&gt;
trace id 530fa6dd inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
trace id 87a375ea inet filter input packet: iif lo &lt;br /&gt;
trace id 87a375ea inet filter input rule iif lo accept (verdict accept)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tracing two different kind of packets at the same monitor session:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft filter input tcp dport 10000 nftrace set 1&lt;br /&gt;
% nft filter input icmp type echo-request nftrace set 1&lt;br /&gt;
% nft -nn monitor trace&lt;br /&gt;
trace id e1f5055f ip filter input packet: iif eth0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 ip saddr 192.168.122.1 ip daddr 192.168.122.83 ip tos 0 ip ttl 64 ip id 32315 ip length 84 icmp type echo-request icmp code 0 icmp id 10087 icmp sequence 1&lt;br /&gt;
trace id e1f5055f ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id e1f5055f ip filter input verdict continue&lt;br /&gt;
trace id e1f5055f ip filter input&lt;br /&gt;
trace id 74e47ad2 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 0 ip ttl 64 ip id 49030 ip length 84 icmp type echo-request icmp code 0 icmp id 10095 icmp sequence 1&lt;br /&gt;
trace id 74e47ad2 ip filter input rule icmp type echo-request nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 74e47ad2 ip filter input verdict continue&lt;br /&gt;
trace id 74e47ad2 ip filter input&lt;br /&gt;
trace id 3030de23 ip filter input packet: iif vlan0 ether saddr 63:f6:4b:00:54:52 ether daddr c9:4b:a9:00:54:52 vlan pcp 0 vlan cfi 1 vlan id 1000 ip saddr 10.0.0.1 ip daddr 10.0.0.2 ip tos 16 ip ttl 64 ip id 59062 ip length 60 tcp sport 55438 tcp dport 10000 tcp flags == syn tcp window 29200&lt;br /&gt;
trace id 3030de23 ip filter input rule tcp dport 10000 nftrace set 1 (verdict continue)&lt;br /&gt;
trace id 3030de23 ip filter input verdict continue&lt;br /&gt;
trace id 3030de23 ip filter input&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=552</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=552"/>
		<updated>2020-10-28T21:13:19Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Possible actions on packets */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=551</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=551"/>
		<updated>2020-10-28T21:11:45Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Possible actions on packets */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&lt;br /&gt;
* [[Tracing rule evaluation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=550</id>
		<title>Setting packet connection tracking metainformation</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=550"/>
		<updated>2020-10-20T10:41:11Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* helpers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You can set some bits of the packet conntrack metainformation, apart of [[Matching connection tracking stateful metainformation | matching on it]].&lt;br /&gt;
&lt;br /&gt;
== notrack ==&lt;br /&gt;
&lt;br /&gt;
You can use the &#039;&#039;&#039;notrack&#039;&#039;&#039; support to explicitly skip connection tracking for matching packets.&lt;br /&gt;
&lt;br /&gt;
The example below skips traffic for 80/tcp and 443/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add rule ip raw prerouting tcp dport { 80, 443 } notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please, note that you should use notrack before the kernel connection tracking is triggered.&lt;br /&gt;
Use a chain with priority -300. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add table raw&lt;br /&gt;
nft add chain raw prerouting { type filter hook prerouting priority -300 \; }&lt;br /&gt;
nft add rule raw prerouting tcp dport 80 notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support for this was added in linux kernel 4.9 and in nftables v0.7.&lt;br /&gt;
&lt;br /&gt;
== helpers ==&lt;br /&gt;
&lt;br /&gt;
You can assign each packet a conntrack helper.&lt;br /&gt;
&lt;br /&gt;
Instantiate a helper, using a named object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
table filter {&lt;br /&gt;
      ct helper sip-5060 {&lt;br /&gt;
             type &amp;quot;sip&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper tftp-69 {&lt;br /&gt;
             type &amp;quot;tftp&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper ftp-standard {&lt;br /&gt;
             type &amp;quot;ftp&amp;quot; protocol tcp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      chain c {&lt;br /&gt;
             type filter hook prerouting priority 0;&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your chain priority must be &amp;gt; -200, because conntrack registers at this priority.&lt;br /&gt;
Otherwise, packets will not find any conntrack information (which is required&lt;br /&gt;
to attach the helper).&lt;br /&gt;
&lt;br /&gt;
Then, from the rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new tcp dport 21 ct helper set &amp;quot;ftp-standard&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 5060 ct helper set &amp;quot;sip-5060&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 69 ct helper set &amp;quot;tftp-69&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can of course use a dictionary, one single rule to assign many helpers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new ct helper set ip protocol . th dport map { \&lt;br /&gt;
                        udp . 69 : &amp;quot;tftp-69&amp;quot;, \&lt;br /&gt;
                        udp . 5060 : &amp;quot;sip-5060&amp;quot;, \&lt;br /&gt;
                        tcp . 21 : &amp;quot;ftp-standard&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which sets the helper based in the transport protocol number and the transport destination port.&lt;br /&gt;
&lt;br /&gt;
You need nftables &amp;gt;= 0.8 and the kernel &amp;gt;= 4.12 to use this feature.&lt;br /&gt;
&lt;br /&gt;
In case of a previous version of nftables, you can enable automatic assignment with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/netfilter/nf_conntrack_helper&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, with the sysctl parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
net.netfilter.nf_conntrack_helper = 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=549</id>
		<title>Setting packet connection tracking metainformation</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=549"/>
		<updated>2020-10-20T10:40:21Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* helpers */ update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You can set some bits of the packet conntrack metainformation, apart of [[Matching connection tracking stateful metainformation | matching on it]].&lt;br /&gt;
&lt;br /&gt;
== notrack ==&lt;br /&gt;
&lt;br /&gt;
You can use the &#039;&#039;&#039;notrack&#039;&#039;&#039; support to explicitly skip connection tracking for matching packets.&lt;br /&gt;
&lt;br /&gt;
The example below skips traffic for 80/tcp and 443/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add rule ip raw prerouting tcp dport { 80, 443 } notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please, note that you should use notrack before the kernel connection tracking is triggered.&lt;br /&gt;
Use a chain with priority -300. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add table raw&lt;br /&gt;
nft add chain raw prerouting { type filter hook prerouting priority -300 \; }&lt;br /&gt;
nft add rule raw prerouting tcp dport 80 notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support for this was added in linux kernel 4.9 and in nftables v0.7.&lt;br /&gt;
&lt;br /&gt;
== helpers ==&lt;br /&gt;
&lt;br /&gt;
You can assign each packet a conntrack helper.&lt;br /&gt;
&lt;br /&gt;
Instantiate a helper, using a named object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
table filter {&lt;br /&gt;
      ct helper sip-5060 {&lt;br /&gt;
             type &amp;quot;sip&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper tftp-69 {&lt;br /&gt;
             type &amp;quot;tftp&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper ftp-standard {&lt;br /&gt;
             type &amp;quot;ftp&amp;quot; protocol tcp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      chain c {&lt;br /&gt;
             type filter hook prerouting priority 0;&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your chain priority must be &amp;gt; -200, because conntrack registers at this priority.&lt;br /&gt;
Otherwise, packets will not have any conntrack information (which is a requirement&lt;br /&gt;
to &lt;br /&gt;
&lt;br /&gt;
Then, from the rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new tcp dport 21 ct helper set &amp;quot;ftp-standard&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 5060 ct helper set &amp;quot;sip-5060&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 69 ct helper set &amp;quot;tftp-69&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can of course use a dictionary, one single rule to assign many helpers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new ct helper set ip protocol . th dport map { \&lt;br /&gt;
                        udp . 69 : &amp;quot;tftp-69&amp;quot;, \&lt;br /&gt;
                        udp . 5060 : &amp;quot;sip-5060&amp;quot;, \&lt;br /&gt;
                        tcp . 21 : &amp;quot;ftp-standard&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which sets the helper based in the transport protocol number and the transport destination port.&lt;br /&gt;
&lt;br /&gt;
You need nftables &amp;gt;= 0.8 and the kernel &amp;gt;= 4.12 to use this feature.&lt;br /&gt;
&lt;br /&gt;
In case of a previous version of nftables, you can enable automatic assignment with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/netfilter/nf_conntrack_helper&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, with the sysctl parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
net.netfilter.nf_conntrack_helper = 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=548</id>
		<title>Setting packet connection tracking metainformation</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=548"/>
		<updated>2020-10-20T10:30:33Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* helpers */ restrict it to ct state new&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You can set some bits of the packet conntrack metainformation, apart of [[Matching connection tracking stateful metainformation | matching on it]].&lt;br /&gt;
&lt;br /&gt;
== notrack ==&lt;br /&gt;
&lt;br /&gt;
You can use the &#039;&#039;&#039;notrack&#039;&#039;&#039; support to explicitly skip connection tracking for matching packets.&lt;br /&gt;
&lt;br /&gt;
The example below skips traffic for 80/tcp and 443/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add rule ip raw prerouting tcp dport { 80, 443 } notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please, note that you should use notrack before the kernel connection tracking is triggered.&lt;br /&gt;
Use a chain with priority -300. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add table raw&lt;br /&gt;
nft add chain raw prerouting { type filter hook prerouting priority -300 \; }&lt;br /&gt;
nft add rule raw prerouting tcp dport 80 notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support for this was added in linux kernel 4.9 and in nftables v0.7.&lt;br /&gt;
&lt;br /&gt;
== helpers ==&lt;br /&gt;
&lt;br /&gt;
You can assign each packet a conntrack helper.&lt;br /&gt;
&lt;br /&gt;
Instantiate a helper, using a named object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
table filter {&lt;br /&gt;
      ct helper sip-5060 {&lt;br /&gt;
             type &amp;quot;sip&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper tftp-69 {&lt;br /&gt;
             type &amp;quot;tftp&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper ftp-standard {&lt;br /&gt;
             type &amp;quot;ftp&amp;quot; protocol tcp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      chain c {&lt;br /&gt;
             type filter hook prerouting priority 0;&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, from the rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new tcp dport 21 ct helper set &amp;quot;ftp-standard&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 5060 ct helper set &amp;quot;sip-5060&amp;quot;&lt;br /&gt;
nft add rule filter c ct state new udp dport 69 ct helper set &amp;quot;tftp-69&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can of course use a dictionary, one single rule to assign many helpers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct state new ct helper set ip protocol . th dport map { \&lt;br /&gt;
                        udp . 69 : &amp;quot;tftp-69&amp;quot;, \&lt;br /&gt;
                        udp . 5060 : &amp;quot;sip-5060&amp;quot;, \&lt;br /&gt;
                        tcp . 21 : &amp;quot;ftp-standard&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which sets the helper based in the transport protocol number and the transport destination port.&lt;br /&gt;
&lt;br /&gt;
You need nftables &amp;gt;= 0.8 and the kernel &amp;gt;= 4.12 to use this feature.&lt;br /&gt;
&lt;br /&gt;
In case of a previous version of nftables, you can enable automatic assignment with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/netfilter/nf_conntrack_helper&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, with the sysctl parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
net.netfilter.nf_conntrack_helper = 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=547</id>
		<title>Setting packet connection tracking metainformation</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Setting_packet_connection_tracking_metainformation&amp;diff=547"/>
		<updated>2020-10-20T10:25:10Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* helpers */ update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You can set some bits of the packet conntrack metainformation, apart of [[Matching connection tracking stateful metainformation | matching on it]].&lt;br /&gt;
&lt;br /&gt;
== notrack ==&lt;br /&gt;
&lt;br /&gt;
You can use the &#039;&#039;&#039;notrack&#039;&#039;&#039; support to explicitly skip connection tracking for matching packets.&lt;br /&gt;
&lt;br /&gt;
The example below skips traffic for 80/tcp and 443/tcp:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add rule ip raw prerouting tcp dport { 80, 443 } notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please, note that you should use notrack before the kernel connection tracking is triggered.&lt;br /&gt;
Use a chain with priority -300. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft add table raw&lt;br /&gt;
nft add chain raw prerouting { type filter hook prerouting priority -300 \; }&lt;br /&gt;
nft add rule raw prerouting tcp dport 80 notrack&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Support for this was added in linux kernel 4.9 and in nftables v0.7.&lt;br /&gt;
&lt;br /&gt;
== helpers ==&lt;br /&gt;
&lt;br /&gt;
You can assign each packet a conntrack helper.&lt;br /&gt;
&lt;br /&gt;
Instantiate a helper, using a named object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
table filter {&lt;br /&gt;
      ct helper sip-5060 {&lt;br /&gt;
             type &amp;quot;sip&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper tftp-69 {&lt;br /&gt;
             type &amp;quot;tftp&amp;quot; protocol udp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      ct helper ftp-standard {&lt;br /&gt;
             type &amp;quot;ftp&amp;quot; protocol tcp;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      chain c {&lt;br /&gt;
             type filter hook prerouting priority 0;&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, from the rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c tcp dport 21 ct helper set &amp;quot;ftp-standard&amp;quot;&lt;br /&gt;
nft add rule filter c udp dport 5060 ct helper set &amp;quot;sip-5060&amp;quot;&lt;br /&gt;
nft add rule filter c udp dport 69 ct helper set &amp;quot;tftp-69&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can of course use a dictionary, one single rule to assign many helpers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
nft add rule filter c ct helper set ip protocol . th dport map { \&lt;br /&gt;
                        udp . 69 : &amp;quot;tftp-69&amp;quot;, \&lt;br /&gt;
                        udp . 5060 : &amp;quot;sip-5060&amp;quot;, \&lt;br /&gt;
                        tcp . 21 : &amp;quot;ftp-standard&amp;quot; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which sets the helper based in the transport protocol number and the transport destination port.&lt;br /&gt;
&lt;br /&gt;
You need nftables &amp;gt;= 0.8 and the kernel &amp;gt;= 4.12 to use this feature.&lt;br /&gt;
&lt;br /&gt;
In case of a previous version of nftables, you can enable automatic assignment with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
echo 1 &amp;gt; /proc/sys/net/netfilter/nf_conntrack_helper&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, with the sysctl parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
net.netfilter.nf_conntrack_helper = 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=546</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=546"/>
		<updated>2020-10-20T10:17:00Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Possible actions on packets */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=545</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=545"/>
		<updated>2020-10-20T10:16:40Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Possible actions on packets */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset to nftables]]&lt;br /&gt;
* [[Output text modifiers]]&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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&lt;br /&gt;
* [[Attaching connection tracking helpers]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=544</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=544"/>
		<updated>2020-09-28T16:39:19Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Listing meters */ fix listing of set&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Meters ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dynamic sets/maps&#039;&#039;&#039; or meters are a way to use maps with stateful objects. They used to be known as &#039;&#039;flow tables&#039;&#039; before nft v0.8.1 and Linux kernel 4.3.&lt;br /&gt;
&lt;br /&gt;
Among other things, they provide a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables. However, meters are a lot more flexible since you can use any selector, one or many through [[concatenations]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note that the &#039;&#039;meter&#039;&#039; keyword is obsolete, the dynamic set and map syntax is now preferred for consistency.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Using meters ==&lt;br /&gt;
&lt;br /&gt;
The following commands create a table named &#039;&#039;my_filter_table&#039;&#039;, a chain named &#039;&#039;my_input_chain&#039;&#039; which hooks incoming traffic and a rule that uses a meter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add table my_filter_table&lt;br /&gt;
% nft add chain my_filter_table my_input_chain {type filter hook input priority 0\;}&lt;br /&gt;
% nft add set my_filter_table my_ssh_meter { type ipv4_addr\; flags dynamic \;}&lt;br /&gt;
% nft add rule my_filter_table my_input_chain tcp dport 22 ct state new add @my_ssh_meter { 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; TCP &#039;&#039;ssh&#039;&#039; (port 22) connections, which uses a dynamic set named &#039;&#039;my_ssh_meter&#039;&#039; to limit the traffic rate to 10 connections 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 set my_filter_table my_ssh_meter { type ipv4_addr . inet_service\; flags timeout, dynamic \;}&lt;br /&gt;
% nft add rule my_filter_table my_input_chain tcp dport 22 ct state new add @my_ssh_meter { ip saddr . tcp dport timeout 60s limit rate 10/second } accept&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule counts incoming connections (packets with state &#039;&#039;new&#039;&#039;) based on the tuple &#039;&#039;(IP source address, TCP destination port)&#039;&#039;, the counters are dropped after 60 seconds without update.&lt;br /&gt;
&lt;br /&gt;
== Listing meters ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the meter use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list set my_filter_table my_ssh_meter&lt;br /&gt;
table ip my_filter_table {&lt;br /&gt;
        set my_ssh_meter {&lt;br /&gt;
                type ipv4_addr&lt;br /&gt;
                size 65535&lt;br /&gt;
                flags dynamic&lt;br /&gt;
                elements = { 10.141.10.2 limit rate 10/second }&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Doing connlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Since 4.18, there is a new &#039;&#039;ct count&#039;&#039; selector that allows you to count the number of existing connections. This extension uses the information available in the Connection Tracking System table, therefore, the counting of connection is based on the existing entries in the table.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to do &#039;&#039;connlimit&#039;&#039; from nftables:&lt;br /&gt;
&lt;br /&gt;
 table ip my_filter_table {&lt;br /&gt;
        set my_connlimit {&lt;br /&gt;
                type ipv4_addr&lt;br /&gt;
                size 65535&lt;br /&gt;
                flags dynamic&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        chain my_output_chain {&lt;br /&gt;
                type filter hook output priority filter; policy accept;&lt;br /&gt;
                ct state new add @my_connlimit { ip daddr ct count over 20 } counter packets 0 bytes 0 drop&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The example above dynamically populates the set &#039;&#039;connlimit&#039;&#039; from the packet path. For the first packet of each connection (ie. packets matching &#039;&#039;ct state new&#039;&#039;), this adds an entry into &#039;&#039;connlimit&#039;&#039; set, this entry uses the IPv4 destination address as a key. If the number of connections goes over 20, then packets are dropped.&lt;br /&gt;
&lt;br /&gt;
Since &#039;&#039;connlimit&#039;&#039; is a set, you can perform any operation on it, such as listing and flushing its content.&lt;br /&gt;
&lt;br /&gt;
== Doing iptables hashlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Meters replace iptables hashlimit in nft. From iptables v1.6.2 onward, you can use the tool &#039;&#039;&#039;iptables-translate&#039;&#039;&#039; to see how to translate hashlimit rules.&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 meter. All modes are available except no mode, a meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter 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 meter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter, also notice that meters, 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 meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meters.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Simple_rule_management&amp;diff=543</id>
		<title>Simple rule management</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Simple_rule_management&amp;diff=543"/>
		<updated>2020-09-25T07:56:40Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Removing all the rules in a chain */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Appending new rules =&lt;br /&gt;
&lt;br /&gt;
To add new rules, you have to specify the corresponding table and the chain that you want to use, eg.&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 ip daddr 8.8.8.8 counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &#039;&#039;filter&#039;&#039; is the table and &#039;&#039;output&#039;&#039; is the chain. The example above adds a rule to match all packets seen by the output chain whose destination is 8.8.8.8, in case of matching it updates the rule counters. Note that counters are optional in &#039;&#039;nftables&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For those familiar with iptables, the rule appending is equivalent to &#039;&#039;-A&#039;&#039; command in iptables.&lt;br /&gt;
&lt;br /&gt;
= Listing rules =&lt;br /&gt;
&lt;br /&gt;
You can list the rules that are contained by a table 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 list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip daddr 8.8.8.8 counter packets 0 bytes 0&lt;br /&gt;
                 tcp dport ssh counter packets 0 bytes 0&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also list rules by chain, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list chain filter ouput&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip daddr 8.8.8.8 counter packets 0 bytes 0&lt;br /&gt;
                 tcp dport ssh counter packets 0 bytes 0&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are plenty of [[Output_text_modifiers | output text modifiers]] than can be used when listing your rules, to for example, translate IP addresses to DNS names, TCP protocols, etc.&lt;br /&gt;
&lt;br /&gt;
= Testing your rule =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test this rule with a simple ping to 8.8.8.8:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% ping -c 1 8.8.8.8&lt;br /&gt;
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 8.8.8.8: icmp_req=1 ttl=64 time=1.31 ms&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, if we list the rule-set, we obtain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft -nn list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip daddr 8.8.8.8 counter packets 1 bytes 84&lt;br /&gt;
                 tcp dport 22 counter packets 0 bytes 0&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the counters have been updated.&lt;br /&gt;
&lt;br /&gt;
= Adding a rule at a given position =&lt;br /&gt;
&lt;br /&gt;
If you want to add a rule at a given position, you have to use the handle as reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter -n -a&lt;br /&gt;
table filter {&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip protocol tcp counter packets 82 bytes 9680 # handle 8&lt;br /&gt;
                 ip saddr 127.0.0.1 ip daddr 127.0.0.6 drop # handle 7&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to add a rule after the rule with handler number 8, you have to type:&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 position 8 ip daddr 127.0.0.8 drop &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you can check the effect of that command by listing the rule-set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter -n -a&lt;br /&gt;
table filter {&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip protocol tcp counter packets 190 bytes 21908 # handle 8&lt;br /&gt;
                 ip daddr 127.0.0.8 drop # handle 10&lt;br /&gt;
                 ip saddr 127.0.0.1 ip daddr 127.0.0.6 drop # handle 7&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to insert a rule before the rule with handler number 8, you have to type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft insert rule filter output position 8 ip daddr 127.0.0.8 drop &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Removing rules =&lt;br /&gt;
&lt;br /&gt;
You have to obtain the &#039;&#039;handle&#039;&#039; to delete a rule via the &#039;&#039;&#039;-a&#039;&#039;&#039; option. The &#039;&#039;handle&#039;&#039; is automagically assigned by the kernel and it uniquely identifies the rule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter -a&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain output {&lt;br /&gt;
                 type filter hook output priority 0;&lt;br /&gt;
                 ip daddr 192.168.1.1 counter packets 1 bytes 84 # handle 5&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete the rule whose handle is &#039;&#039;5&#039;&#039; 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 delete rule filter output handle 5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: There are plans to support rule deletion by passing:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft delete rule filter output ip saddr 192.168.1.1 counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
but this is &#039;&#039;&#039;not&#039;&#039;&#039; yet implemented. So you&#039;ll have to use the handle to delete rules until that feature is implemented.&lt;br /&gt;
&lt;br /&gt;
= Removing all the rules in a chain =&lt;br /&gt;
&lt;br /&gt;
You can delete &#039;&#039;&#039;all the rules&#039;&#039;&#039; in a chain 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 flush rule filter output&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also delete &#039;&#039;&#039;all the rules&#039;&#039;&#039; in a table 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 flush table filter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Prepending new rules =&lt;br /&gt;
&lt;br /&gt;
To prepend new rules through the &#039;&#039;insert&#039;&#039; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft insert rule filter output ip daddr 192.168.1.1 counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This prepends a rule that will update per-rule packet and bytes counters for traffic addressed to 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
The equivalent in iptables is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% iptables -I OUTPUT -t filter -d 192.168.1.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that iptables always provides per-rule counters.&lt;br /&gt;
&lt;br /&gt;
= Replacing rules =&lt;br /&gt;
&lt;br /&gt;
You can replace any rule via the &#039;&#039;replace&#039;&#039; command by indicating the rule handle. Therefore, first you have to list the ruleset with option &#039;&#039;-a&#039;&#039; to obtain the rule handle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# nft list ruleset -a&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                type filter hook input priority 0; policy accept;&lt;br /&gt;
                ip protocol tcp counter packets 0 bytes 0 # handle 2&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, assuming you want to replace rule with handle number 2, you have to specify this handle number and the new rule that you want to place instead of it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nft replace rule filter input handle 2 counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, when listing back the ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# nft list ruleset -a&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                counter packets 0 bytes 0 &lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can effective note that the rule has been replaced by a simple rule that counts any packets, instead of counting TCP packets as the previous rule was doing.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=519</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=519"/>
		<updated>2020-06-24T11:13:34Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159144250132190&amp;amp;w=2 nftables 0.9.5 release] (This release broke &#039;&#039;&#039;vmap&#039;&#039;&#039; support, this is fixed in 0.9.6)&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=158575148505527&amp;amp;w=2 nftables 0.9.4 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=157532146917292&amp;amp;w=2 nftables 0.9.3 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=518</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=518"/>
		<updated>2020-06-24T11:12:06Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159144250132190&amp;amp;w=2 nftables 0.9.5 release] (This release broke &#039;&#039;&#039;vmap&#039;&#039;&#039; support, this is fixed in 0.9.6)&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=158575148505527&amp;amp;w=2 nftables 0.9.4 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=517</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=517"/>
		<updated>2020-06-24T11:10:59Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=158575148505527&amp;amp;w=2 nftables 0.9.4 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=516</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=516"/>
		<updated>2020-06-24T11:10:10Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=158583434604821&amp;amp;w=2 nftables 0.9.4 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=515</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=515"/>
		<updated>2020-06-24T11:10:02Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=158583434604821&amp;amp;w=2 nftables 0.9.5 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=514</id>
		<title>List of updates in the nft command line tool</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=List_of_updates_in_the_nft_command_line_tool&amp;diff=514"/>
		<updated>2020-06-24T11:09:12Z</updated>

		<summary type="html">&lt;p&gt;Admin: initial page, link to 0.9.6&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains links to the release announcements:&lt;br /&gt;
&lt;br /&gt;
* [https://marc.info/?l=netfilter&amp;amp;m=159225380419197&amp;amp;w=2 nftables 0.9.6 release]&lt;br /&gt;
&lt;br /&gt;
The cover letter usually includes a description of the updates and examples to follow track of the updates in the userspace command line tool.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Main_Page&amp;diff=513</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=513"/>
		<updated>2020-06-24T11:06:46Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Development */&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;
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;
= 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;
* [[Adoption]]&lt;br /&gt;
* [[Legacy xtables tools]]&lt;br /&gt;
* [[How to obtain help/support]]&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;
* [[nftables families|Understanding nftables families]]&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;
* [[Moving from ipset 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;
* [[Mangle TCP options]]&lt;br /&gt;
* [[Counters]]&lt;br /&gt;
* [[Load balancing]]&lt;br /&gt;
* [[Setting packet connection tracking metainformation]]&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;
* [[Meters|Metering]] (formerly known as flow tables before nftables 0.8.1 release)&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;
* [[Flowtable]] (the fastpath network stack bypass)&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;
* [[Simple ruleset for a server]]&lt;br /&gt;
* [[Bridge filtering]]&lt;br /&gt;
* [[Multiple NATs using nftables maps]]&lt;br /&gt;
* [[Classic perimetral firewall example]]&lt;br /&gt;
* [[Port knocking example]]&lt;br /&gt;
* [[Classification to tc structure example]]&lt;br /&gt;
* [[Using configuration management systems]] (like puppet, ansible, etc)&lt;br /&gt;
* [[GeoIP matching]]&lt;br /&gt;
&lt;br /&gt;
= Development =&lt;br /&gt;
&lt;br /&gt;
Check [[Portal:DeveloperDocs|Portal:DeveloperDocs - documentation for netfilter developers]].&lt;br /&gt;
&lt;br /&gt;
Some hints on the general development progress:&lt;br /&gt;
&lt;br /&gt;
* [[List of updates since Linux kernel 3.13]]&lt;br /&gt;
* [[List of updates in the nft command line tool]]&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;
= External links =&lt;br /&gt;
&lt;br /&gt;
Watch some 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;
* Watch [https://www.youtube.com/watch?v=CaYp0d2wiuU#t=1m47s The ultimate packet classifier for GNU/Linux], thanks to the FSFE for paying my trip to Barcelona and for recommending me as speaker to the KDE Spanish branch.&lt;br /&gt;
* [https://www.youtube.com/watch?v=Sy0JDX451ns Florian Westphal - Why nftables?]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=qXVOA2MKA1s Netdev 2.1 - Netfilter workshop]&lt;br /&gt;
* Watch [https://youtu.be/iCj10vEKPrw Netdev 2.2 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://youtu.be/0hqfzp6tpZo Netdev 0x12 - Netf‌ilter mini-workshop]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=0wQfSfDVN94 NLUUG - Goodbye iptables, Hello nftables]&lt;br /&gt;
* Watch [https://www.youtube.com/watch?v=Uf5ULkEWPL0 LCA2018 - nftables from a user perspective]&lt;br /&gt;
&lt;br /&gt;
Additional documentations and articles:&lt;br /&gt;
&lt;br /&gt;
* Tutorial [https://zasdfgbnm.github.io/2017/09/07/Extending-nftables/ Extending nftables by Xiang Gao]&lt;br /&gt;
* Article [http://ral-arturo.org/2017/05/05/debian-stretch-stable-nftables.html New in Debian stable Stretch: nftables]&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;br /&gt;
&lt;br /&gt;
To Eric Leblond, for boostrapping the [https://home.regit.org/netfilter-en/nftables-quick-howto/ Nftables quick howto] in 2013.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Building_and_installing_nftables_from_sources&amp;diff=498</id>
		<title>Building and installing nftables from sources</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Building_and_installing_nftables_from_sources&amp;diff=498"/>
		<updated>2020-03-26T10:06:54Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Installing userspace libraries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;nftables requires several userspace libraries, the &#039;nft&#039; userspace command line utility and the kernel modules.&lt;br /&gt;
&lt;br /&gt;
If you are using a major linux distribution, you may consider using [[nftables from distributions]].&lt;br /&gt;
&lt;br /&gt;
= Installing userspace libraries =&lt;br /&gt;
&lt;br /&gt;
You have to install the following userspace libraries:&lt;br /&gt;
&lt;br /&gt;
* [http://www.netfilter.org/projects/libmnl libmnl ], this library provides the interfaces to communicate kernel and userspace via Netlink. &#039;&#039;It is very likely that your distribution already provides a package for libmnl that you can use&#039;&#039;. If you decide to use your distributor package, make sure you install the development package as well.&lt;br /&gt;
&lt;br /&gt;
* [http://www.netfilter.org/projects/libnftnl libnftnl], this library provides the low-level API to transform netlink messages to objects.&lt;br /&gt;
&lt;br /&gt;
You also need &#039;&#039;libgmp&#039;&#039; and &#039;&#039;libreadline&#039;&#039;, most distributions already provide packages for these two libraries, so make sure you install the development extensions of this packages to successfully compile &#039;&#039;nftables&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If you plan to give a test to &#039;&#039;nftables&#039;&#039;, we recommend you to use git snapshots for &#039;&#039;libnftnl&#039;&#039; and &#039;&#039;nft&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installing userspace libraries from git ==&lt;br /&gt;
&lt;br /&gt;
To install &#039;&#039;libnftnl&#039;&#039;, to can type these magic spells:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git clone git://git.netfilter.org/libnftnl&lt;br /&gt;
$ cd libnftnl&lt;br /&gt;
$ sh autogen.sh&lt;br /&gt;
$ ./configure&lt;br /&gt;
$ make&lt;br /&gt;
$ sudo make install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you are working behind proxy than it might possible that you are not able to clone using git protocol so try to clone using &amp;quot;http/https:&amp;quot; instead &amp;quot;git:&amp;quot;&lt;br /&gt;
&amp;lt;br &amp;gt; Reasons:- 1) The git protocol, by default, uses the port 9418. It might possible that your traffic is blocked on that port.&lt;br /&gt;
&amp;lt;br &amp;gt; 2) Also take help and can relate from the [http://stackoverflow.com/a/28494985 solution] &lt;br /&gt;
&lt;br /&gt;
If you have any compilation problem, please report them to the [https://www.netfilter.org/mailinglists.html netfilter developer mailing list] providing as much detailed information as possible.&lt;br /&gt;
&lt;br /&gt;
== Installing userspace libraries from snapshots ==&lt;br /&gt;
&lt;br /&gt;
You can retrieve daily snapshots of this library from the [ftp://ftp.netfilter.org/pub/libnftnl/snapshot/ Netfilter FTP]. Then, to install it you have to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ wget ftp://ftp.netfilter.org/pub/libnftnl/snapshot/libnftnl-20140217.tar.bz2&lt;br /&gt;
$ tar xvjf libnftnl-20140217.tar.bz2&lt;br /&gt;
$ ./configure&lt;br /&gt;
$ make&lt;br /&gt;
$ sudo make install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing userspace nft command line utility =&lt;br /&gt;
&lt;br /&gt;
This is the command line utility that provides a user interface to configure &#039;&#039;nftables&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installing from git ==&lt;br /&gt;
&lt;br /&gt;
Just type these commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% git clone git://git.netfilter.org/nftables&lt;br /&gt;
% cd nftables&lt;br /&gt;
% sh autogen.sh&lt;br /&gt;
% ./configure&lt;br /&gt;
% make&lt;br /&gt;
% make install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should check that &#039;&#039;nft&#039;&#039; is installed in your system by typing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft&lt;br /&gt;
nft: no command specified&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That means &#039;&#039;nft&#039;&#039; has been correctly installed.&lt;br /&gt;
&lt;br /&gt;
= Installing Linux kernel with nftables support =&lt;br /&gt;
&lt;br /&gt;
Prerequisites: nftables is available in Linux kernels since version 3.13 but this is software under development, so we encourage you to run the latest stable kernel.&lt;br /&gt;
&lt;br /&gt;
== Validating your installation ==&lt;br /&gt;
&lt;br /&gt;
You can validate that your installation is working by checking if you can install the &#039;nf_tables&#039; kernel module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% modprobe nf_tables&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you can check that&#039;s actually there via &#039;&#039;lsmod&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# lsmod | grep nf_tables&lt;br /&gt;
nf_tables              42349  0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
dmesg should show the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% dmesg&lt;br /&gt;
...&lt;br /&gt;
[13939.468020] nf_tables: (c) 2007-2009 Patrick McHardy &amp;lt;kaber@trash.net&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you also have loaded the family support, eg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% modprobe nf_tables_ipv4&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;lsmod&#039;&#039; command should show something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# lsmod | grep nf_tables&lt;br /&gt;
nf_tables_ipv4         12869  0 &lt;br /&gt;
nf_tables              42349  1 nf_tables_ipv4&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other family modules are &#039;&#039;nf_tables_ipv6&#039;&#039;, &#039;&#039;nf_tables_bridge&#039;&#039;, &#039;&#039;nf_tables_arp&#039;&#039; and (since Linux kernel &amp;gt;= 3.14) &#039;&#039;nf_tables_inet&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These modules provide the corresponding [[Configuring_tables|table]] and the filter [[Configuring_chains|chain]] support for the given family.&lt;br /&gt;
&lt;br /&gt;
You could also check which modules are supported by your current kernel. How to to do this, depends on your distro:&lt;br /&gt;
* on debian, look in /boot/config-XXX-YYY, where XXX is your kernel package version, and YYY is your arch, e.g. /boot/config-4.2.0-1-amd64&lt;br /&gt;
* on Arch, look in /proc/config.gz. As this is compressed, use a command such as zcat or zgrep.&lt;br /&gt;
&lt;br /&gt;
In the debian example below, CONFIG_NFT_REDIR_IPV4 and CONFIG_NFT_REDIR_IPV6 are not set, so you can&#039;t use [http://wiki.nftables.org/wiki-nftables/index.php/Performing_Network_Address_Translation_(NAT)#Redirect redirect] in the ruleset:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% grep CONFIG_NFT_ /boot/config-4.2.0-1-amd64&lt;br /&gt;
CONFIG_NFT_EXTHDR=m&lt;br /&gt;
CONFIG_NFT_META=m&lt;br /&gt;
CONFIG_NFT_CT=m&lt;br /&gt;
CONFIG_NFT_RBTREE=m&lt;br /&gt;
CONFIG_NFT_HASH=m&lt;br /&gt;
CONFIG_NFT_COUNTER=m&lt;br /&gt;
CONFIG_NFT_LOG=m&lt;br /&gt;
CONFIG_NFT_LIMIT=m&lt;br /&gt;
CONFIG_NFT_MASQ=m&lt;br /&gt;
CONFIG_NFT_REDIR=m&lt;br /&gt;
CONFIG_NFT_NAT=m&lt;br /&gt;
CONFIG_NFT_QUEUE=m&lt;br /&gt;
CONFIG_NFT_REJECT=m&lt;br /&gt;
CONFIG_NFT_REJECT_INET=m&lt;br /&gt;
CONFIG_NFT_COMPAT=m&lt;br /&gt;
CONFIG_NFT_CHAIN_ROUTE_IPV4=m&lt;br /&gt;
CONFIG_NFT_REJECT_IPV4=m&lt;br /&gt;
CONFIG_NFT_CHAIN_NAT_IPV4=m&lt;br /&gt;
CONFIG_NFT_MASQ_IPV4=m&lt;br /&gt;
# CONFIG_NFT_REDIR_IPV4 is not set&lt;br /&gt;
CONFIG_NFT_CHAIN_ROUTE_IPV6=m&lt;br /&gt;
CONFIG_NFT_REJECT_IPV6=m&lt;br /&gt;
CONFIG_NFT_CHAIN_NAT_IPV6=m&lt;br /&gt;
CONFIG_NFT_MASQ_IPV6=m&lt;br /&gt;
# CONFIG_NFT_REDIR_IPV6 is not set&lt;br /&gt;
CONFIG_NFT_BRIDGE_META=m&lt;br /&gt;
CONFIG_NFT_BRIDGE_REJECT=m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing from git ==&lt;br /&gt;
&lt;br /&gt;
This is slower as you will retrieve the Linux kernel git tree for nftables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nftables.git&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After retrieving the git tree, you have to follow the same steps that described in the installation from sources.&lt;br /&gt;
&lt;br /&gt;
But you will get the most recent changes for the &#039;&#039;nftables&#039;&#039; kernel code there.&lt;br /&gt;
&lt;br /&gt;
When configuring the kernel, be sure to enable all the nftables modules (choose &#039;m&#039; or &#039;y&#039;). This is an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ make oldconfig&lt;br /&gt;
&lt;br /&gt;
Netfilter Xtables support (required for ip_tables) (NETFILTER_XTABLES) [M/y/?] m&lt;br /&gt;
Netfilter nf_tables support (NF_TABLES) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables payload module (NFT_PAYLOAD) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables IPv6 exthdr module (NFT_EXTHDR) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables meta module (NFT_META) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables conntrack module (NFT_CT) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables rbtree set module (NFT_RBTREE) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables hash set module (NFT_HASH) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables counter module (NFT_COUNTER) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables log module (NFT_LOG) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables limit module (NFT_LIMIT) [N/m] (NEW) m&lt;br /&gt;
  Netfilter nf_tables nat module (NFT_NAT) [N/m] (NEW) m&lt;br /&gt;
  Netfilter x_tables over nf_tables module (NFT_COMPAT) [N/m/?] (NEW) m&lt;br /&gt;
&lt;br /&gt;
IPv4 nf_tables support (NF_TABLES_IPV4) [N/m] (NEW) m&lt;br /&gt;
  nf_tables IPv4 reject support (NFT_REJECT_IPV4) [N/m] (NEW) m&lt;br /&gt;
  IPv4 nf_tables route chain support (NFT_CHAIN_ROUTE_IPV4) [N/m] (NEW) m&lt;br /&gt;
  IPv4 nf_tables nat chain support (NFT_CHAIN_NAT_IPV4) [N/m] (NEW) m&lt;br /&gt;
&lt;br /&gt;
IPv6 nf_tables support (NF_TABLES_IPV6) [M/n] m&lt;br /&gt;
  IPv6 nf_tables route chain support (NFT_CHAIN_ROUTE_IPV6) [M/n] m&lt;br /&gt;
  IPv6 nf_tables nat chain support (NFT_CHAIN_NAT_IPV6) [M/n] m&lt;br /&gt;
&lt;br /&gt;
Ethernet Bridge nf_tables support (NF_TABLES_BRIDGE) [N/m/y] (NEW) m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=428</id>
		<title>Jumping to chain</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=428"/>
		<updated>2019-07-23T19:40:47Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Like in &#039;&#039;iptables&#039;&#039;, you can structure your rule-set in using a tree of [[Configuring chains|chains]]. To do so, you first need to create the non-base chain via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above creates the &#039;&#039;tcp-chain&#039;&#039; which will be used to add rules to filter tcp traffic, eg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter input ip protocol tcp jump tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can just add a simple rule to that &#039;&#039;tcp-chain&#039;&#039; to count packets and bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter tcp-chain counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The listing should show something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
                 ip protocol tcp jump tcp-chain&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain tcp-chain {&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The counters should update by generating simple TCP traffic.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You can only jump to non-base chains.&lt;br /&gt;
&lt;br /&gt;
== jump vs goto ==&lt;br /&gt;
&lt;br /&gt;
Please note the difference between &#039;&#039;&#039;jump&#039;&#039;&#039; and &#039;&#039;&#039;goto&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* If you use &#039;&#039;&#039;jump&#039;&#039;&#039; to get packet processed in another chain, packet will return to the chain of the calling rule after the end.&lt;br /&gt;
&lt;br /&gt;
* However, if you use &#039;&#039;&#039;goto&#039;&#039;&#039;, packets will be processed in another chain but &#039;&#039;&#039;they will not return&#039;&#039;&#039; to the chain of the calling rule. In this case, the default policy applied to the packet will be the default policy of the original base chain which started processing the packet.&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;jump&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 jump other-chain&lt;br /&gt;
                 # this is the 3º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;goto&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 # default policy &#039;accept&#039; will be applied after other-chain ends processing&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 goto other-chain&lt;br /&gt;
                 # this rule will never be reached by this packet!&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that only jump and goto actions to &#039;&#039;&#039;non-base chains&#039;&#039;&#039; are allowed.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=427</id>
		<title>Jumping to chain</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=427"/>
		<updated>2019-07-23T19:40:24Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Like in &#039;&#039;iptables&#039;&#039;, you can structure your rule-set in using a tree of [[Configuring chains|chains]]. To do so, you first need to create the non-base chain via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above creates the &#039;&#039;tcp-chain&#039;&#039; which will be used to add rules to filter tcp traffic, eg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter input ip protocol tcp jump tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can just add a simple rule to that &#039;&#039;tcp-chain&#039;&#039; to count packets and bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter tcp-chain counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The listing should show something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
                 ip protocol tcp jump tcp-chain&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain tcp-chain {&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The counters should update by generating simple TCP traffic.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You can only jump to non-base chains.&lt;br /&gt;
&lt;br /&gt;
== jump vs goto ==&lt;br /&gt;
&lt;br /&gt;
Please note the difference between &#039;&#039;&#039;jump&#039;&#039;&#039; and &#039;&#039;&#039;goto&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* If you use &#039;&#039;&#039;jump&#039;&#039;&#039; to get packet processed in another chain, packet will return to the chain of the calling rule after the end.&lt;br /&gt;
&lt;br /&gt;
* However, if you use &#039;&#039;&#039;goto&#039;&#039;&#039;, packets will be processed in another chain but &#039;&#039;&#039;they will not return&#039;&#039;&#039; to the chain of the calling rule. In this case, the default policy applied to the packet will be the default policy of the original base chain which started processing the packet.&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;jump&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 jump other-chain&lt;br /&gt;
                 # this is the 3º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;goto&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 # default policy &#039;accept&#039; will be applied after other-chain ends processing&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 goto other-chain&lt;br /&gt;
                 # this rule will never be reached by this packet!&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that only jump and goto actions to &#039;&#039;&#039;base chains&#039;&#039;&#039; are allowed.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=426</id>
		<title>Jumping to chain</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=426"/>
		<updated>2019-07-23T19:39:49Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Like in &#039;&#039;iptables&#039;&#039;, you can structure your rule-set in using a tree of [[Configuring chains|chains]]. To do so, you first need to create the non-base chain via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above creates the &#039;&#039;tcp-chain&#039;&#039; which will be used to add rules to filter tcp traffic, eg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter input ip protocol tcp jump tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can just add a simple rule to that &#039;&#039;tcp-chain&#039;&#039; to count packets and bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter tcp-chain counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The listing should show something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
                 ip protocol tcp jump tcp-chain&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain tcp-chain {&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The counters should update by generating simple TCP traffic.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You can only jump to non-base chains.&lt;br /&gt;
&lt;br /&gt;
== jump vs goto ==&lt;br /&gt;
&lt;br /&gt;
Please note the difference between &#039;&#039;&#039;jump&#039;&#039;&#039; and &#039;&#039;&#039;goto&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* If you use &#039;&#039;&#039;jump&#039;&#039;&#039; to get packet processed in another chain, packet will return to the chain of the calling rule after the end.&lt;br /&gt;
&lt;br /&gt;
* However, if you use &#039;&#039;&#039;goto&#039;&#039;&#039;, packets will be processed in another chain but &#039;&#039;&#039;they will not return&#039;&#039;&#039; to the chain of the calling rule. In this case, the default policy applied to the packet will be the default policy of the original base chain which started processing the packet.&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;jump&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 jump other-chain&lt;br /&gt;
                 # this is the 3º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;goto&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 # default policy &#039;accept&#039; will be applied after other-chain ends processing&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 goto other-chain&lt;br /&gt;
                 # this rule will never be reached by this packet!&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that only jump and goto actions to basechains are not allowed.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=425</id>
		<title>Jumping to chain</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Jumping_to_chain&amp;diff=425"/>
		<updated>2019-07-23T19:39:35Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Like in &#039;&#039;iptables&#039;&#039;, you can structure your rule-set in using a tree of [[Configuring chains|chains]]. To do so, you first need to create the non-base chain via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add chain ip filter tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example above creates the &#039;&#039;tcp-chain&#039;&#039; which will be used to add rules to filter tcp traffic, eg.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter input ip protocol tcp jump tcp-chain&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can just add a simple rule to that &#039;&#039;tcp-chain&#039;&#039; to count packets and bytes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add rule ip filter tcp-chain counter&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The listing should show something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list table filter&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0;&lt;br /&gt;
                 ip protocol tcp jump tcp-chain&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain tcp-chain {&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The counters should update by generating simple TCP traffic.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; You can only jump to non-base chains.&lt;br /&gt;
&lt;br /&gt;
== jump vs goto ==&lt;br /&gt;
&lt;br /&gt;
Please note the difference between &#039;&#039;&#039;jump&#039;&#039;&#039; and &#039;&#039;&#039;goto&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* If you use &#039;&#039;&#039;jump&#039;&#039;&#039; to get packet processed in another chain, packet will return to the chain of the calling rule after the end.&lt;br /&gt;
&lt;br /&gt;
* However, if you use &#039;&#039;&#039;goto&#039;&#039;&#039;, packets will be processed in another chain but &#039;&#039;&#039;they will not return&#039;&#039;&#039; to the chain of the calling rule. In this case, the default policy applied to the packet will be the default policy of the original base chain which started processing the packet.&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;jump&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 jump other-chain&lt;br /&gt;
                 # this is the 3º matching rule&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of &#039;&#039;&#039;goto&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
Packet is: SRC=1.1.1.1 DST=2.2.2.2 TCP SPORT 111 DPORT 222&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
table ip filter {&lt;br /&gt;
        chain input {&lt;br /&gt;
                 type filter hook input priority 0; policy accept;&lt;br /&gt;
                 # this is the 1º matching rule&lt;br /&gt;
                 # default policy &#039;accept&#039; will be applied after other-chain ends processing&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 goto other-chain&lt;br /&gt;
                 # this rule will never be reached by this packet!&lt;br /&gt;
                 ip saddr 1.1.1.1 ip daddr 2.2.2.2 tcp sport 111 tcp dport 222 accept&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        chain other-chain {&lt;br /&gt;
                 # this is the 2º matching rule&lt;br /&gt;
                 counter packets 8 bytes 2020&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that only jump and goto actions to basechains are allowed.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=401</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=401"/>
		<updated>2019-07-12T11:22:00Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Meters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Meters ==&lt;br /&gt;
&lt;br /&gt;
This feature used to be known as &#039;&#039;flow tables&#039;&#039; before nft v0.8.1 and Linux kernel 4.3. However, the &#039;&#039;meter&#039;&#039; keyword is obsolete, the dynamic set and map syntax is now preferred for consistency.&lt;br /&gt;
&lt;br /&gt;
Meters are a way to use maps.&lt;br /&gt;
&lt;br /&gt;
Among other things, they provide a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables. However, meters are a lot more flexible since you can use any selector, one or many through [[concatenations]].&lt;br /&gt;
&lt;br /&gt;
== Using meters ==&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 meter:&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 map filter ssh-meter { type ipv4_addr : limit; }&lt;br /&gt;
% nft add rule filter input tcp dport 22 ct state new update @ssh-meter { 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 meter named &#039;&#039;ssh-meter&#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 tcp dport 22 ct state new update @ssh-meter { ip saddr . tcp dport timeout 60s limit rate 10/second } accept&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 meters ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the meter use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list map filter ssh-meter&lt;br /&gt;
table ip filter {&lt;br /&gt;
	map ssh-meter {&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 connlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Since 4.18, there is a new &#039;&#039;ct count&#039;&#039; selector that allows you to count the number of existing connections. This extension uses the information available in the Connection Tracking System table, therefore, the counting of connection is based on the existing entries in the table.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to do &#039;&#039;connlimit&#039;&#039; from nftables:&lt;br /&gt;
&lt;br /&gt;
 table ip filter {&lt;br /&gt;
        set connlimit {&lt;br /&gt;
                type ipv4_addr&lt;br /&gt;
                size 65535&lt;br /&gt;
                flags dynamic&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        chain y {&lt;br /&gt;
                type filter hook output priority filter; policy accept;&lt;br /&gt;
                ct state new add @connlimit { ip daddr ct count over 20 } counter packets 0 bytes 0 drop&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The example above dynamically populates the set &#039;&#039;connlimit&#039;&#039; from the packet path. For the first packet of each connection (ie. packets matching &#039;&#039;ct state new&#039;&#039;), this adds an entry into &#039;&#039;connlimit&#039;&#039; set, this entry uses the IPv4 destination address as a key. If the number of connection goes over 20, then packets are dropped.&lt;br /&gt;
&lt;br /&gt;
Since &#039;&#039;connlimit&#039;&#039; is a set, you can perform any operation on it, such as listing and flushing its content.&lt;br /&gt;
&lt;br /&gt;
== Doing iptables hashlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Meters replace iptables hashlimit in nft. From iptables v1.6.2 onward, you can use the tool &#039;&#039;&#039;iptables-translate&#039;&#039;&#039; to see how to translate hashlimit rules.&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 meter. All modes are available except no mode, a meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter 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 meter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter, also notice that meters, 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 meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meters.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=400</id>
		<title>Meters</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Meters&amp;diff=400"/>
		<updated>2019-07-12T11:19:59Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Listing meters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Meters ==&lt;br /&gt;
&lt;br /&gt;
This feature used to be known as &#039;&#039;flow tables&#039;&#039; before nft v0.8.1.&lt;br /&gt;
&lt;br /&gt;
Since Linux Kernel 4.3 and nft v0.8.1 nftables supports this feature.&lt;br /&gt;
&lt;br /&gt;
Meters provide a native replacement for the &#039;&#039;hashlimit&#039;&#039; match in iptables, however, meters are a lot more flexible since you can use any selector, one or many through [[concatenations]].&lt;br /&gt;
&lt;br /&gt;
== Using meters ==&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 meter:&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 map filter ssh-meter { type ipv4_addr : limit; }&lt;br /&gt;
% nft add rule filter input tcp dport 22 ct state new update @ssh-meter { 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 meter named &#039;&#039;ssh-meter&#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 tcp dport 22 ct state new update @ssh-meter { ip saddr . tcp dport timeout 60s limit rate 10/second } accept&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 meters ==&lt;br /&gt;
&lt;br /&gt;
To list the content matched by the meter use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft list map filter ssh-meter&lt;br /&gt;
table ip filter {&lt;br /&gt;
	map ssh-meter {&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 connlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Since 4.18, there is a new &#039;&#039;ct count&#039;&#039; selector that allows you to count the number of existing connections. This extension uses the information available in the Connection Tracking System table, therefore, the counting of connection is based on the existing entries in the table.&lt;br /&gt;
&lt;br /&gt;
The following example shows how to do &#039;&#039;connlimit&#039;&#039; from nftables:&lt;br /&gt;
&lt;br /&gt;
 table ip filter {&lt;br /&gt;
        set connlimit {&lt;br /&gt;
                type ipv4_addr&lt;br /&gt;
                size 65535&lt;br /&gt;
                flags dynamic&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        chain y {&lt;br /&gt;
                type filter hook output priority filter; policy accept;&lt;br /&gt;
                ct state new add @connlimit { ip daddr ct count over 20 } counter packets 0 bytes 0 drop&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The example above dynamically populates the set &#039;&#039;connlimit&#039;&#039; from the packet path. For the first packet of each connection (ie. packets matching &#039;&#039;ct state new&#039;&#039;), this adds an entry into &#039;&#039;connlimit&#039;&#039; set, this entry uses the IPv4 destination address as a key. If the number of connection goes over 20, then packets are dropped.&lt;br /&gt;
&lt;br /&gt;
Since &#039;&#039;connlimit&#039;&#039; is a set, you can perform any operation on it, such as listing and flushing its content.&lt;br /&gt;
&lt;br /&gt;
== Doing iptables hashlimit with nft ==&lt;br /&gt;
&lt;br /&gt;
Meters replace iptables hashlimit in nft. From iptables v1.6.2 onward, you can use the tool &#039;&#039;&#039;iptables-translate&#039;&#039;&#039; to see how to translate hashlimit rules.&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 meter. All modes are available except no mode, a meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter 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 meter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ iptables-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meter, also notice that meters, 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 meter 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-translate -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;
nft add rule ip filter INPUT tcp dport 80 meter 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 meters.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>