XTABLES-NFT(8)

๐Ÿ“ฆ
version 1.8.13 ยท 2 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ XTABLES-NFT(8) โ€” iptables using nftables kernel api โœจ

๐Ÿ’– NAME

xtables-nft โ€” iptables using nftables kernel api ๐ŸŽ€

๐ŸŒธ DESCRIPTION

okay so xtables-nft are versions of iptables that use the nftables API ๐Ÿ’… bestie, this is a whole set of tools that helps the sysadmin migrate their ruleset from iptables(8), ip6tables(8), arptables(8), and ebtables(8) over to nftables(8) ๐Ÿฆ‹

The xtables-nft set is made up of several commands ๐Ÿงš:

  • iptables-nft
  • iptables-nft-save
  • iptables-nft-restore
  • ip6tables-nft
  • ip6tables-nft-save
  • ip6tables-nft-restore
  • arptables-nft
  • ebtables-nft

ngl these tools use the libxtables framework extensions and hook into the nf_tables kernel subsystem through the nft_compat module โœจ

๐Ÿ’œ USAGE

the xtables-nft tools let you manage the nf_tables backend using the native syntax of iptables(8), ip6tables(8), arptables(8), and ebtables(8) ๐Ÿซถ

you should use the xtables-nft tools exactly the same way you'd use the corresponding original tools, no cap ๐Ÿ’…

adding a rule will result in that rule being added to the nf_tables kernel subsystem instead ๐Ÿ”ฅ and listing the ruleset will use the nf_tables backend as well ๐Ÿ‘‘

when these tools were designed, the main idea was to replace each legacy binary with a symlink to the xtables-nft program, like this ๐ŸŒˆ:

/sbin/iptables -> /usr/sbin/iptables-nft-multi
/sbin/ip6tables -> /usr/sbin/ip6tables-nft-multi
/sbin/arptables -> /usr/sbin/arptables-nft-multi
/sbin/ebtables -> /usr/sbin/ebtables-nft-multi

the iptables version string tells you whether the legacy API (get/setsockopt) or the new nf_tables api is being used ๐Ÿ‘€

iptables -V
iptables v1.7 (nf_tables)

๐Ÿฆ‹ DIFFERENCES TO LEGACY IPTABLES

the xtables-nft tools use the nf_tables kernel API, so rule additions and deletions are always atomic โœจ unlike iptables-legacy, iptables-nft -A .. will NOT need to grab the current ruleset from the kernel, change it, and reload the altered ruleset ๐Ÿ™…โ€โ™€๏ธ instead, iptables-nft just tells the kernel to add one rule ๐Ÿ’– which is why the iptables-legacy --wait option is a no-op in iptables-nft ๐Ÿฅฑ

using the xtables-nft tools lets you monitor ruleset changes with the xtables-monitor(8) command ๐Ÿ‘€

heads up ๐Ÿ˜ญ: when you use -j TRACE to debug packet traversal through the ruleset, you'll need to run xtables-monitor(8) in --trace mode to actually see the monitoring trace events ๐Ÿ’€

๐ŸŽ€ EXAMPLES

one basic example is creating the skeleton ruleset in nf_tables from the xtables-nft tools on a fresh machine ๐Ÿ“:

root@machine:~# iptables-nft -L
[...]
root@machine:~# ip6tables-nft -L
[...]
root@machine:~# arptables-nft -L
[...]
root@machine:~# ebtables-nft -L
[...]
root@machine:~# nft list ruleset
table ip filter {
     chain INPUT {
          type filter hook input priority 0; policy accept;
     }

     chain FORWARD {
          type filter hook forward priority 0; policy accept;
     }

     chain OUTPUT {
          type filter hook output priority 0; policy accept;
     }
}
table ip6 filter {
     chain INPUT {
          type filter hook input priority 0; policy accept;
     }

     chain FORWARD {
          type filter hook forward priority 0; policy accept;
     }

     chain OUTPUT {
          type filter hook output priority 0; policy accept;
     }
}
table bridge filter {
     chain INPUT {
          type filter hook input priority -200; policy accept;
     }

     chain FORWARD {
          type filter hook forward priority -200; policy accept;
     }

     chain OUTPUT {
          type filter hook output priority -200; policy accept;
     }
}
table arp filter {
     chain INPUT {
          type filter hook input priority 0; policy accept;
     }

     chain FORWARD {
          type filter hook forward priority 0; policy accept;
     }

     chain OUTPUT {
          type filter hook output priority 0; policy accept;
     }
}

(please note that on fresh machines, listing the ruleset for the first time results in all tables and chains being created ๐Ÿงš)

to migrate your complete filter ruleset, in the case of iptables(8), you would use ๐Ÿ’…:

root@machine:~# iptables-legacy-save > myruleset # reads from x_tables
root@machine:~# iptables-nft-restore myruleset   # writes to nf_tables

or

root@machine:~# iptables-legacy-save | iptables-translate-restore | less

to see how rules would look in the nft nft(8) syntax ๐ŸŒธ

๐Ÿšง LIMITATIONS

you should use Linux kernel >= 4.17 ๐Ÿซถ

the CLUSTERIP target is not supported ๐Ÿ˜ญ

to get up-to-date info about this, head to http://wiki.nftables.org/ ๐Ÿ’œ

๐Ÿ”— SEE ALSO

nft(8), xtables-translate(8), xtables-monitor(8) โœจ

๐Ÿ‘‘ AUTHORS

the nftables framework is written by the Netfilter project (https://www.netfilter.org) ๐ŸŒˆ

this manual page was written by Arturo Borrero Gonzalez <arturo@debian.org> for the Debian project, but others are allowed to use it too ๐ŸŽ€

this documentation is free/libre under the terms of the GPLv2+ ๐Ÿฆ‹


and that's a wrap, bestie ๐Ÿซถ this was XTABLES-NFT(8) from June 2018, so go show it some love ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from