nftables
Original author(s) | Patrick McHardy |
---|---|
Developer(s) | Patrick McHardy/Pablo Neira |
Stable release | 0.6[1]
/ June 2, 2016 |
Preview release | |
Repository | |
Written in | C |
Operating system | Linux |
Platform | Netfilter |
Type | packet filtering |
License | GPL (version 2) |
Website |
![](http://upload.wikimedia.org/wikipedia/commons/thumb/6/65/Simplified_Structure_of_the_Linux_Kernel.svg/220px-Simplified_Structure_of_the_Linux_Kernel.svg.png)
tc
relates to the Linux kernel packet scheduler as iptables
to netfilter and nft
to nftables. All are user-space CLI-programs that are used to configure their respective Linux kernel subsystem.nftables is a subsystem of the Linux kernel providing filtering and classification of network packets/datagrams/frames. It has been available since Linux kernel 3.13 released on 19 January 2014.[2]
nftables is supposed to replace netfilter. Both subsystems have been co-authored by Patrick McHardy. Among the advantages of nftables over netfilter is less code duplication and more throughput. nftables is configured via the user-space utility nft while netfilter is configured via the utilities iptables, ip6tables, arptables and ebtables frameworks.
nftables utilizes the building blocks of the Netfilter infrastructure, such as the existing hooks into the networking stack, connection tracking system, userspace queueing component, and logging subsystem.
nft
command line syntax
A command to drop any packages with the destination IP address 1.2.3.4
nft add rule ip filter output ip daddr 1.2.3.4 drop
The syntax of iptables is different:
iptables -t filter -A OUTPUT -j DROP -d 1.2.3.4
Also, there is a planned compatibility layer for the translation of already existing iptables firewall rules into their nftables equivalents.[citation needed]
History
The project was first publicly presented at Netfilter Workshop 2008, by Patrick McHardy from the Netfilter Core Team.[3] The first preview release of kernel and userspace implementation was given in March 2009.[4] Although the tool has been called, "...the biggest change to Linux firewalling since the introduction of iptables in 2001", it has received little press.[5] Notable hacker Fyodor Vaskovich (Gordon Lyon) said that he is "looking forward to its general release in the mainstream Linux kernel."[5]
The project stayed in alpha stage and the official website was removed in 2009. In March 2010, emails from the author on the project mailing lists showed the project was still active and approaching a beta release,[6][7] but the latter was never shipped officially. In October 2012, Pablo Neira Ayuso proposed a compatibility layer for iptables[8] and announced a possible inclusion of the project into mainstream kernel.
On 16 October 2013, Pablo Neira Ayuso submitted a nftables core pull request to the Linux kernel mainline tree.[9] It was merged into the kernel mainline on 19 January 2014, with the release of Linux kernel version 3.13.[2]
Overview
nftables kernel engine adds a simple virtual machine into the Linux kernel, which is able to execute bytecode to inspect a network packet and make decisions on how that packet should be handled. The operations implemented by this virtual machine are intentionally made basic. It can get data from the packet itself, have a look at the associated metadata (inbound interface, for example), and manage connection tracking data. Arithmetic, bitwise and comparison operators can be used for making decisions based on that data. The virtual machine is also capable of manipulating sets of data (typically IP addresses), allowing multiple comparison operations to be replaced with a single set lookup.[10]
The above-described organization is contrary to the iptables firewalling code, which has protocol awareness built-in so deeply into the logic, that the code has had to be replicated four times—for IPv4, IPv6, ARP, and Ethernet bridging—as the firewall engines are too protocol-specific to be used in a generic manner.[10]
The main advantages of nftables over iptables are the simplification of the Linux kernel ABI, reduction of code duplication, improved error reporting, and more efficient execution, storage and incremental changes of filtering rules. Traditionally used , , and (for IPv4, IPv6, ARP and Ethernet bridging, respectively) are intended to be replaced with as a single unified implementation, providing firewall configuration on top of the in-kernel virtual machine.
nftables also offers an improved userspace API that allows atomic replacements of one or more firewall rules within a single Netlink transaction. That speeds up firewall configuration changes for setups having large rulesets; it can also help in avoiding race conditions while the rule changes are being executed. Also, a planned compatibility layer is going to provide translation of already existing iptables firewall rules into their nftables equivalents.[10]
References
- ^ "News of the netfilter/iptables project". netfilter.org. 2016-06-02. Retrieved 2015-09-30.
- ^ a b "nftables, the successor of iptables". Linux 3.13. kernelnewbies.org. 2014-01-19. Retrieved 2016-03-04.
- ^ "User day program - NFWS2008". Workshop.netfilter.org. 2008-10-03. Retrieved 2014-02-22.
- ^ initial release announcement
- ^ a b Gray, Patrick (March 26, 2009). "NEWS: Linux Gets New Firewall". Risky.biz.
- ^ "Linux Netfilter Devel - Re: Current state of nftables". Spinics.net. Retrieved 2014-01-20.
- ^ "Linux Netfilter Devel - Re: Current state of nftables". Spinics.net. Retrieved 2014-01-20.
- ^ "Linux Netfilter Devel - [RFC] back on nf_tables (plus compatibility layer)". Spinics.net. Retrieved 2014-01-20.
- ^ "'[PATCH 00/17] netfilter updates: nf_tables pull request' - MARC". Marc.info. Retrieved 2014-01-20.
- ^ a b c Jonathan Corbet (2013-08-20). "The return of nftables". LWN.net. Retrieved 2013-10-22.
External links
- Official website
- nftables Git source code repository
- nftables HOWTO documentation
- First release of nftables (2009-03-18)
- Pablo Neira Ayuso: [RFC] back on nf_tables (plus compatibility layer)
- nftables quick HOWTO
- nftables sections in ArchWiki and Gentoo Wiki
- Corbet, Jonathan (2009-03-24). "nftables: a new packet filtering engine". LWN.net.
- McHardy, Patrick (2008-09-30). nftables – a successor to iptables, ip6tables, ebtables and arptables (ODP). Netfilter Workshop 2008.
{{cite conference}}
: External link in
(help); Unknown parameter|conferenceurl=
|conferenceurl=
ignored (|conference-url=
suggested) (help) - nft_compat extended to support ebtables extensions (merged in Linux kernel 4.0)