Site icon The Ultimate Linux Newbie Guide

Hello nftables, Goodbye iptables

netfilter

Firewalling under Linux gets revamped.

Yep, you read it right. The firewalling tool that has been either hated or loved, ever since Kernel 2.4 is being phased out from kernel v4.9 onwards in favour of nftables.

Iptables will still be available for the forseeable future, however now is the time to learn the new syntax of nftables. Nftables, which stands for netfilter tables. Nftables is part of the netfilter suite, which is a team of kernel contributors specifically tasked at doing “NAT, Firewalling and packet mangling for Linux”. The netfilter team are the same authors that brought us iptables, so they are arguably best placed to replace iptables, just like ipchains and ipfw before it.

New functionality

The Linux Netfilter team in 2016

Nftables offers new functionality unavailable in iptables, and has been available (although not fully stable) since Kernel 3.13. Ontop of the kernel module itself, three other components comprise nftables. These are:

The new toolset offers the following advantages over iptables:

Can I convert my iptables rules to nft easily?

Fairly easily. There is a conversion tool which works as following:
% iptables-translate -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
nft add rule ip filter INPUT tcp dport 22 ct state new counter accept


% ip6tables-translate -A FORWARD -i eth0 -o eth3 -p udp -m multiport --dports 111,222 -j ACCEPT
nft add rule ip6 filter FORWARD iifname eth0 oifname eth3 meta l4proto udp udp dport {111,222} counter accept

When is it coming to my Linux distribution?

Starting with Debian 9 stable, the nftables framework is installed, ready to use. It is available through package installation in Debian development (Stretch) right now, simply type aptitude install nftables.

A release to Debian stable will almost certainly trickle the release downstream to all of the other major Debian based distributions such as Ubuntu in the near future. CentOS 7/RHEL 7 users can install nftables from the official Red Hat EPEL repo using yum today. At the time of writing CentOS ships version 0.6 and Debian 0.7. Ubuntu 16.04 LTS does have an older version (0.5), however I’d recommend waiting for a later version.

More information

To get further information, head over to the netfilter website, they have some really good documentation:

Exit mobile version