Type iptables -V on a current Debian or Ubuntu machine and the answer ends in (nf_tables). The command that generations of Linux guides taught is, on most modern systems, a translator: it accepts the old syntax and writes rules into nftables, the framework that replaced it. That arrangement mostly works. It also allows one kind of mistake, a rule set that no single tool can see in full, which blocked a port in the test below while the main firewall listing showed it wide open. Everything here was tested with iptables 1.8.10 and nftables 1.0.9, in two isolated network namespaces joined by a virtual cable, one acting as a server with listeners on ports 22, 80 and 8080.
Same kernel firewall, two front ends
The history in two lines
The nftables project wiki describes nftables as the framework new code should use instead of the legacy iptables, ip6tables, arptables and ebtables infrastructure, available in Linux kernels from 3.13 onward. The Debian wiki’s nftables page says nftables has been Debian’s default firewall framework since Debian 10, “Buster,” and that iptables is deprecated.
Why iptables still works
The same Debian page explains that even when iptables is installed, it actually uses nftables through a compatibility layer called iptables-nft. The test machine showed it plainly:
$ iptables -V
iptables v1.8.10 (nf_tables)
A second copy, iptables-legacy, talks to the older kernel subsystem. The nftables wiki’s page on the legacy tools says all the old setsockopt-based tools are now considered legacy and carry a -legacy suffix, while the new ones carry -nft. Both versions accept identical commands, which is exactly why mixing them up is easy.
What actually improved
The wiki lists the gains: a generic set infrastructure for building sets and maps, no predefined tables or chains, simpler handling of IPv4 and IPv6 together, and better support for changing rules on the fly. In practice, the differences that matter day to day are sets, the inet family that covers both IP versions in one table, and loading a whole rule file in one step.

The same firewall, written both ways
In iptables
The test firewall allowed SSH and web traffic, kept replies working, and dropped everything else:
iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
From the client namespace, ports 22 and 80 connected and port 8080 timed out, which is what a dropped packet looks like from outside.
What iptables-nft wrote
Listing the nftables ruleset afterwards showed where those commands went:
# Warning: table ip filter is managed by iptables-nft, do not touch!
table ip filter {
chain INPUT {
type filter hook input priority filter; policy drop;
iifname "lo" counter packets 0 bytes 0 accept
ct state related,established counter packets 6 bytes 312 accept
tcp dport 22 counter packets 1 bytes 60 accept
tcp dport 80 counter packets 1 bytes 60 accept
}
}
Every iptables rule became an nftables rule with a counter attached. The warning at the top matters: that table belongs to the compatibility layer, and editing it with nft directly can confuse iptables later.
In native nftables
The equivalent written for nftables directly, as a file:
flush ruleset
table inet filter {
set allowed_tcp {
type inet_service
elements = { 22, 80 }
}
chain input {
type filter hook input priority filter; policy drop;
iif "lo" accept
ct state established,related accept
tcp dport @allowed_tcp counter accept
tcp dport 8080 counter reject with tcp reset
}
}
Three differences stand out. The table is inet, so one set of rules covers IPv4 and IPv6, where iptables needs a separate ip6tables ruleset. The open ports live in a named set. And nothing exists until the file creates it: the wiki’s point that nftables has no predefined tables or chains means the input chain is just a name, and the hook input line is what attaches it to incoming traffic.
Translating old rules
One command at a time
The nftables wiki’s migration page points to iptables-translate, which prints the nftables version of any iptables command. On the test machine:
$ iptables-translate -A INPUT -p tcp --dport 22 -j ACCEPT
nft 'add rule ip filter INPUT tcp dport 22 counter accept'
$ iptables-translate -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
nft 'add rule ip filter INPUT ct state related,established counter accept'
$ iptables-translate -A INPUT -p tcp -m multiport --dports 22,80,443 -j ACCEPT
nft 'add rule ip filter INPUT ip protocol tcp tcp dport { 22, 80, 443 } counter accept'
The last one shows the syntax getting shorter. The multiport module becomes an anonymous set in curly braces.
A whole ruleset at once
The same page describes iptables-restore-translate, which takes a saved iptables ruleset and converts it in one pass. Its output can be loaded straight into nftables. The translators ship with iptables itself and handle both iptables and ip6tables rules.
What translation doesn’t do
The translated rules land in an ip family table, IPv4 only, mirroring the original. Merging IPv4 and IPv6 rules into one inet table, or collapsing a long list of ports into a named set, is a rewrite the tools leave to a person.

Sets, reject, and atomic loading
Changing a set without touching rules
With the open ports in a named set, opening another port is one command:
nft add element inet filter allowed_tcp '{ 8080 }'
Port 8080 went from refused to open immediately, with no rule edited and no reload. Sets can also hold IP addresses and ranges, which is how blocklists with thousands of entries stay manageable.
Drop vs reject, measured
The native ruleset rejected port 8080 with a TCP reset, and the test also added a plain drop rule for port 9000. From the client, with a 3-second timeout:
| Port | Rule | Client saw | Time |
|---|---|---|---|
| 8080 | reject with tcp reset |
Connection refused | 0.035 s |
| 9000 | drop |
Timeout | 3.04 s |
A reject tells the other side immediately that nothing is there. A drop leaves it waiting until it gives up. Drop reveals less to a scanner; reject is friendlier to legitimate programs on a local network that would otherwise hang.
A typo can’t half-load
nft -f loads a file as one transaction. A test file with acept in place of accept failed with a syntax error pointing at the exact line, and the previous ruleset stayed in place untouched, set and all. Running nft -c -f file checks a file without loading it. With iptables, a script of individual commands that fails halfway leaves the firewall half-built until someone notices.
The hidden ruleset problem
Two tools, one packet
The migration page carries a short warning: beware of using the nft and legacy tools at the same time, because that means using both the x_tables and nf_tables kernel subsystems at once, which could lead to unexpected results.
The test showed what “unexpected” looks like. With the native nftables ruleset accepting port 80, one extra rule went in through the legacy tool:
iptables-legacy -A INPUT -p tcp --dport 80 -j DROP
Port 80 stopped answering. The packet had to pass both rule sets, and the legacy one dropped it.
Why it is hard to spot
nft list ruleset showed only the nftables rules, including the accept for port 80. The drop rule appeared nowhere in that output. The clue came from the other direction: running iptables -S (the nft version) printed a warning at the top, iptables-legacy tables present, use iptables-legacy to see them. Anyone debugging with only nft would see a firewall that allows port 80 and a port that doesn’t work.
Flushing the legacy rules with iptables-legacy -F brought port 80 back.
Where legacy rules come from
Old scripts, container tools and VPN software sometimes call iptables-legacy directly or bring their own copy of iptables. A quick check on any machine where a port behaves strangely: run both iptables-legacy -S and nft list ruleset, and treat any output from the first as a second firewall that needs explaining.

Which to use
For new setups
On a distribution where nftables is the default, writing rules in nftables syntax in a single file, usually /etc/nftables.conf on Debian-based systems, gives sets, one table for both IP versions and all-or-nothing loading. The test ruleset above is a reasonable starting point for a single server.
When iptables commands are fine
Typing iptables on a modern system is not wrong. It produces nftables rules through iptables-nft, and countless scripts and guides still use it. The trouble starts only when the same machine also runs iptables-legacy, or when someone edits the tables iptables-nft owns with nft by hand.
Front ends
The Debian wiki notes that nftables is a low-level framework designed for experts, and lists front ends such as firewalld for people who would rather not write rules directly. Ubuntu’s ufw is another. Each of them ends up writing rules into the same kernel firewall, and the same check applies when a port misbehaves: look at every ruleset the kernel is enforcing, not only the one the favorite tool displays.
Sources
- What is nftables?, nftables wiki: https://wiki.nftables.org/wiki-nftables/index.php/What_is_nftables%3F
- Moving from iptables to nftables, nftables wiki: https://wiki.nftables.org/wiki-nftables/index.php/Moving_from_iptables_to_nftables
- Legacy xtables tools, nftables wiki: https://wiki.nftables.org/wiki-nftables/index.php/Legacy_xtables_tools
- nftables, Debian Wiki: https://wiki.debian.org/nftables
