nftables: the new packet filter in the Linux kernel
Summary
At the Chemnitz Linux Days 2014, Michael Steinfurth of B1 Systems presented nftables, the new packet filter in the Linux kernel. nftables was set to replace iptables, ip6tables, arptables and ebtables in the medium term. The talk explained the design and the differences from iptables and showed an example migration.
What nftables does better
Under iptables there was a separate tool with its own rules for IPv4, IPv6, ARP and bridges, and a lot of logic was hard-wired in the kernel. nftables replaces this with a single tool called nft and a small virtual machine in the kernel that executes rules. As a result, new filtering options no longer need new kernel modules.
For administrators, nftables brings a more readable syntax, a common table for IPv4 and IPv6, and sets and maps that combine many similar rules into one. Rule changes are also applied atomically, that is, completely or not at all.
What became of it
nftables entered the kernel with Linux 3.13 at the beginning of 2014. The replacement took longer than expected: only around 2019 did Debian 10 and Red Hat Enterprise Linux 8 switch to nftables as the default. Many tools still use the iptables commands, which internally generate nftables rules via a compatibility layer.
Ideas
- A single tool replaces separate filters for IPv4, IPv6, ARP and bridges.
- A small virtual machine in the kernel executes the filter rules.
- Sets and maps combine many similar rules.
Insights
- Replacing fundamental tools often takes many years.
- Compatibility layers make switching easier but obscure what actually happens in the kernel.
Facts
- nftables entered the kernel with Linux 3.13.
- Debian 10 and RHEL 8 use nftables as the default backend.
- The speaker was Michael Steinfurth from B1 Systems GmbH.
References
Remarks
- With iptables-translate, existing iptables rules can be translated into nftables syntax.
Recommendations
- Write new firewall rules directly in nftables and use a common inet table for IPv4 and IPv6.
- Use nft list ruleset to check which rules are actually active, even if tools use iptables commands.
Found a mistake or have something to add? Get in touch.
Links to the original source and the Web Archive open in a new tab.