iptables to nftables Converter
Paste iptables rules or iptables-save output and get an equivalent nftables ruleset.
Client-side only — nothing leaves your browser
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority filter; policy drop;
iifname "lo" accept
ct state established, related accept
ip protocol tcp tcp dport 22 accept
ip protocol tcp tcp dport 80 accept
ip protocol tcp tcp dport 443 accept
meta l4proto icmp accept
log prefix "iptables-dropped: "
drop
}
chain forward {
type filter hook forward priority filter; policy drop;
}
chain output {
type filter hook output priority filter; policy accept;
}
}
table ip nat {
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
iifname "eth0" ip protocol tcp tcp dport 8080 dnat to 10.0.0.5:80
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
oifname "eth0" masquerade
}
}
About the iptables to nftables Migration
nftables is the modern replacement for iptables, ip6tables, arptables, and ebtables on Linux. It replaces the legacy xtables framework with a single, unified syntax built on top of the netfilter subsystem. Most major distributions — including Debian 10+, Ubuntu 20.04+, RHEL 8+, and Arch — ship with nftables as the default backend, and the legacy iptables command is now usually a wrapper (iptables-nft) that translates rules into nftables behind the scenes.
This converter parses an iptables-save dump (or individual -A rules) and emits a clean nftables ruleset using the inet family for filter rules and ip for NAT — the same structure produced by iptables-translate from the nftables project, but in your browser with no install required.
iptables to nftables Syntax Mapping
The most common iptables flags and their nftables equivalents:
| iptables | nftables |
|---|---|
| -p tcp | ip protocol tcp |
| --dport 22 | tcp dport 22 |
| --sport 1024:65535 | tcp sport 1024-65535 |
| -s 192.168.1.0/24 | ip saddr 192.168.1.0/24 |
| -d 10.0.0.1 | ip daddr 10.0.0.1 |
| -i eth0 | iifname "eth0" |
| -o eth1 | oifname "eth1" |
| -m conntrack --ctstate ESTABLISHED,RELATED | ct state established, related |
| -j ACCEPT | accept |
| -j DROP | drop |
| -j REJECT --reject-with tcp-reset | reject with tcp reset |
| -j MASQUERADE | masquerade |
| -j DNAT --to-destination 10.0.0.5:80 | dnat to 10.0.0.5:80 |
| -j SNAT --to-source 1.2.3.4 | snat to 1.2.3.4 |
| -j LOG --log-prefix "drop: " | log prefix "drop: " |
| -N MYCHAIN | chain MYCHAIN { ... } |
| -j MYCHAIN | jump MYCHAIN |
Tables, Chains, and Hooks
In nftables, you create tables explicitly and attach chains to netfilter hooks with a priority. The converter uses these mappings:
| iptables table/chain | nftables family | Hook | Priority |
|---|---|---|---|
| filter / INPUT | inet | input | filter (0) |
| filter / FORWARD | inet | forward | filter (0) |
| filter / OUTPUT | inet | output | filter (0) |
| nat / PREROUTING | ip | prerouting | dstnat (-100) |
| nat / POSTROUTING | ip | postrouting | srcnat (100) |
| mangle / * | inet | (matches chain) | mangle (-150) |
Applying the Converted Ruleset
Save the output as /etc/nftables.conf and load it. Always test interactively over a console you can recover from before enabling at boot:
Frequently Asked Questions
What is the difference between iptables and nftables?
Can iptables and nftables work together on the same system?
Does nftables replace iptables on Debian and Ubuntu?
How do I check whether my system is using iptables or nftables?
Is nftables actually faster than iptables?
Related Tools
Need to manage SSH connections?
SSH Workbench lets you connect, browse files, and manage servers visually.
Try SSH Workbench Free