Blame iptables/xtables-nft.8

Packit 7b22a4
.\"
Packit 7b22a4
.\" (C) Copyright 2016-2017, Arturo Borrero Gonzalez <arturo@netfilter.org>
Packit 7b22a4
.\"
Packit 7b22a4
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
Packit 7b22a4
.\" This is free documentation; you can redistribute it and/or
Packit 7b22a4
.\" modify it under the terms of the GNU General Public License as
Packit 7b22a4
.\" published by the Free Software Foundation; either version 2 of
Packit 7b22a4
.\" the License, or (at your option) any later version.
Packit 7b22a4
.\"
Packit 7b22a4
.\" The GNU General Public License's references to "object code"
Packit 7b22a4
.\" and "executables" are to be interpreted as the output of any
Packit 7b22a4
.\" document formatting or typesetting system, including
Packit 7b22a4
.\" intermediate and printed output.
Packit 7b22a4
.\"
Packit 7b22a4
.\" This manual is distributed in the hope that it will be useful,
Packit 7b22a4
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7b22a4
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7b22a4
.\" GNU General Public License for more details.
Packit 7b22a4
.\"
Packit 7b22a4
.\" You should have received a copy of the GNU General Public
Packit 7b22a4
.\" License along with this manual; if not, see
Packit 7b22a4
.\" <http://www.gnu.org/licenses/>.
Packit 7b22a4
.\" %%%LICENSE_END
Packit 7b22a4
.\"
Packit 7b22a4
.TH XTABLES-NFT 8 "June 2018"
Packit 7b22a4
Packit 7b22a4
.SH NAME
Packit 7b22a4
xtables-nft \(em iptables using nftables kernel api
Packit 7b22a4
Packit 7b22a4
.SH DESCRIPTION
Packit 7b22a4
\fBxtables-nft\fP are versions of iptables that use the nftables API.
Packit 7b22a4
This is a set of tools to help the system administrator migrate the
Packit 7b22a4
ruleset from \fBiptables(8)\fP, \fBip6tables(8)\fP, \fBarptables(8)\fP, and
Packit 7b22a4
\fBebtables(8)\fP to \fBnftables(8)\fP.
Packit 7b22a4
Packit 7b22a4
The \fBxtables-nft\fP set is composed of several commands:
Packit 7b22a4
.IP \[bu] 2
Packit 7b22a4
iptables\-nft
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
iptables\-nft\-save
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
iptables\-nft\-restore
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
ip6tables\-nft
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
ip6tables\-nft\-save
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
ip6tables\-nft\-restore
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
arptables\-nft
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
ebtables\-nft
Packit 7b22a4
Packit 7b22a4
These tools use the libxtables framework extensions and hook to the nf_tables
Packit 7b22a4
kernel subsystem using the \fBnft_compat\fP module.
Packit 7b22a4
Packit 7b22a4
.SH USAGE
Packit 7b22a4
The xtables-nft tools allow you to manage the nf_tables backend using the
Packit 7b22a4
native syntax of \fBiptables(8)\fP, \fBip6tables(8)\fP, \fBarptables(8)\fP, and
Packit 7b22a4
\fBebtables(8)\fP.
Packit 7b22a4
Packit 7b22a4
You should use the xtables-nft tools exactly the same way as you would use the
Packit 7b22a4
corresponding original tools.
Packit 7b22a4
Packit 7b22a4
Adding a rule will result in that rule being added to the nf_tables kernel
Packit 7b22a4
subsystem instead.
Packit 7b22a4
Listing the ruleset will use the nf_tables backend as well.
Packit 7b22a4
Packit 7b22a4
When these tools were designed, the main idea was to replace each legacy binary
Packit 7b22a4
with a symlink to the xtables-nft program, for example:
Packit 7b22a4
Packit 7b22a4
.nf
Packit 7b22a4
	/sbin/iptables -> /usr/sbin/iptables\-nft\-multi
Packit 7b22a4
	/sbin/ip6tables -> /usr/sbin/ip6tables\-nft\-multi
Packit 7b22a4
	/sbin/arptables -> /usr/sbin/arptables\-nft\-multi
Packit 7b22a4
	/sbin/ebtables -> /usr/sbin/ebtables\-nft\-multi
Packit 7b22a4
.fi
Packit 7b22a4
Packit 7b22a4
The iptables version string will indicate whether the legacy API (get/setsockopt) or
Packit 7b22a4
the new nf_tables api is used:
Packit 7b22a4
.nf
Packit 7b22a4
	iptables \-V
Packit 7b22a4
	iptables v1.7 (nf_tables)
Packit 7b22a4
.fi
Packit 7b22a4
Packit 7b22a4
.SH DIFFERENCES TO LEGACY IPTABLES
Packit 7b22a4
Packit 7b22a4
Because the xtables-nft tools use the nf_tables kernel API, rule additions
Packit 7b22a4
and deletions are always atomic.  Unlike iptables-legacy, iptables-nft \-A ..
Packit 7b22a4
will NOT need to retrieve the current ruleset from the kernel, change it, and
Packit 7b22a4
re-load the altered ruleset.  Instead, iptables-nft will tell the kernel to add
Packit 7b22a4
one rule.  For this reason, the iptables-legacy \-\-wait option is a no-op in
Packit 7b22a4
iptables-nft.
Packit 7b22a4
Packit 7b22a4
Use of the xtables-nft tools allow monitoring ruleset changes using the
Packit 7b22a4
.B xtables\-monitor(8)
Packit 7b22a4
command.
Packit 7b22a4
Packit 7b22a4
When using \-j TRACE to debug packet traversal to the ruleset, note that you will need to use
Packit 7b22a4
.B xtables\-monitor(8)
Packit 7b22a4
in \-\-trace mode to obtain monitoring trace events.
Packit 7b22a4
Packit 7b22a4
.SH EXAMPLES
Packit 7b22a4
One basic example is creating the skeleton ruleset in nf_tables from the
Packit 7b22a4
xtables-nft tools, in a fresh machine:
Packit 7b22a4
Packit 7b22a4
.nf
Packit 7b22a4
	root@machine:~# iptables\-nft \-L
Packit 7b22a4
	[...]
Packit 7b22a4
	root@machine:~# ip6tables\-nft \-L
Packit 7b22a4
	[...]
Packit 7b22a4
	root@machine:~# arptables\-nft \-L
Packit 7b22a4
	[...]
Packit 7b22a4
	root@machine:~# ebtables\-nft \-L
Packit 7b22a4
	[...]
Packit 7b22a4
	root@machine:~# nft list ruleset
Packit 7b22a4
	table ip filter {
Packit 7b22a4
		chain INPUT {
Packit 7b22a4
			type filter hook input priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain FORWARD {
Packit 7b22a4
			type filter hook forward priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain OUTPUT {
Packit 7b22a4
			type filter hook output priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
	}
Packit 7b22a4
	table ip6 filter {
Packit 7b22a4
		chain INPUT {
Packit 7b22a4
			type filter hook input priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain FORWARD {
Packit 7b22a4
			type filter hook forward priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain OUTPUT {
Packit 7b22a4
			type filter hook output priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
	}
Packit 7b22a4
	table bridge filter {
Packit 7b22a4
		chain INPUT {
Packit 7b22a4
			type filter hook input priority \-200; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain FORWARD {
Packit 7b22a4
			type filter hook forward priority \-200; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain OUTPUT {
Packit 7b22a4
			type filter hook output priority \-200; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
	}
Packit 7b22a4
	table arp filter {
Packit 7b22a4
		chain INPUT {
Packit 7b22a4
			type filter hook input priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain FORWARD {
Packit 7b22a4
			type filter hook forward priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
Packit 7b22a4
		chain OUTPUT {
Packit 7b22a4
			type filter hook output priority 0; policy accept;
Packit 7b22a4
		}
Packit 7b22a4
	}
Packit 7b22a4
.fi
Packit 7b22a4
Packit 7b22a4
(please note that in fresh machines, listing the ruleset for the first time
Packit 7b22a4
results in all tables an chain being created).
Packit 7b22a4
Packit 7b22a4
To migrate your complete filter ruleset, in the case of \fBiptables(8)\fP,
Packit 7b22a4
you would use:
Packit 7b22a4
Packit 7b22a4
.nf
Packit 7b22a4
	root@machine:~# iptables\-legacy\-save > myruleset # reads from x_tables
Packit 7b22a4
	root@machine:~# iptables\-nft\-restore myruleset   # writes to nf_tables
Packit 7b22a4
.fi
Packit 7b22a4
or
Packit 7b22a4
.nf
Packit 7b22a4
	root@machine:~# iptables\-legacy\-save | iptables-translate-restore | less
Packit 7b22a4
.fi
Packit 7b22a4
Packit 7b22a4
to see how rules would look like in the nft
Packit 7b22a4
\fBnft(8)\fP
Packit 7b22a4
syntax.
Packit 7b22a4
Packit 7b22a4
.SH LIMITATIONS
Packit 7b22a4
You should use \fBLinux kernel >= 4.17\fP.
Packit 7b22a4
Packit 7b22a4
The CLUSTERIP target is not supported.
Packit 7b22a4
Packit 7b22a4
To get up-to-date information about this, please head to
Packit 7b22a4
\fBhttp://wiki.nftables.org/\fP.
Packit 7b22a4
Packit 7b22a4
.SH SEE ALSO
Packit 7b22a4
\fBnft(8)\fP, \fBxtables\-translate(8)\fP, \fBxtables\-monitor(8)\fP
Packit 7b22a4
Packit 7b22a4
.SH AUTHORS
Packit 7b22a4
The nftables framework is written by the Netfilter project
Packit 7b22a4
(https://www.netfilter.org).
Packit 7b22a4
Packit 7b22a4
This manual page was written by Arturo Borrero Gonzalez
Packit 7b22a4
<arturo@debian.org> for the Debian project, but may be used by others.
Packit 7b22a4
Packit 7b22a4
This documentation is free/libre under the terms of the GPLv2+.