Blame iptables/xtables-translate.8

Packit 7b22a4
.\"
Packit 7b22a4
.\" (C) Copyright 2018, 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 IPTABLES-TRANSLATE 8 "May 14, 2019"
Packit 7b22a4
Packit 7b22a4
.SH NAME
Packit 7b22a4
iptables-translate \(em translation tool to migrate from iptables to nftables
Packit 7b22a4
.P
Packit 7b22a4
ip6tables-translate \(em translation tool to migrate from ip6tables to nftables
Packit 7b22a4
.SH DESCRIPTION
Packit 7b22a4
There is a set of tools to help the system administrator translate a given
Packit 7b22a4
ruleset from \fBiptables(8)\fP and \fBip6tables(8)\fP to \fBnftables(8)\fP.
Packit 7b22a4
Packit 7b22a4
The available commands are:
Packit 7b22a4
Packit 7b22a4
.IP \[bu] 2
Packit 7b22a4
iptables-translate
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
iptables-restore-translate
Packit 7b22a4
.IP \[bu] 2
Packit 7b22a4
ip6tables-translate
Packit 7b22a4
.IP \[bu]
Packit 7b22a4
ip6tables-restore-translate
Packit 7b22a4
Packit 7b22a4
.SH USAGE
Packit 7b22a4
They take as input the original \fBiptables(8)\fP/\fBip6tables(8)\fP syntax and
Packit 7b22a4
output the native \fBnftables(8)\fP syntax.
Packit 7b22a4
Packit 7b22a4
The \fBiptables-restore-translate\fP tool reads a ruleset in the syntax
Packit 7b22a4
produced by \fBiptables-save(8)\fP. Likewise, the
Packit 7b22a4
\fBip6tables-restore-translate\fP tool reads one produced by
Packit 7b22a4
\fBip6tables-save(8)\fP.  No ruleset modifications occur, these tools are
Packit 7b22a4
text converters only.
Packit 7b22a4
Packit 7b22a4
The \fBiptables-translate\fP reads a command line as if it was entered to
Packit 7b22a4
\fBiptables(8)\fP, and \fBip6tables-translate\fP reads a command like as if it
Packit 7b22a4
was entered to \fBip6tables(8)\fP.
Packit 7b22a4
Packit 7b22a4
.SH EXAMPLES
Packit 7b22a4
Basic operation examples.
Packit 7b22a4
Packit 7b22a4
Single command translation:
Packit 7b22a4
Packit 7b22a4
.nf
Packit 7b22a4
root@machine:~# iptables-translate -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
Packit 7b22a4
nft add rule ip filter INPUT tcp dport 22 ct state new counter accept
Packit 7b22a4
Packit 7b22a4
root@machine:~# ip6tables-translate -A FORWARD -i eth0 -o eth3 -p udp -m multiport --dports 111,222 -j ACCEPT
Packit 7b22a4
nft add rule ip6 filter FORWARD iifname eth0 oifname eth3 meta l4proto udp udp dport { 111,222} counter accept
Packit 7b22a4
.fi
Packit 7b22a4
Packit 7b22a4
Whole ruleset translation:
Packit 7b22a4
Packit 7b22a4
.nf
Packit 7b22a4
root@machine:~# iptables-save > save.txt
Packit 7b22a4
root@machine:~# cat save.txt
Packit 7b22a4
# Generated by iptables-save v1.6.0 on Sat Dec 24 14:26:40 2016
Packit 7b22a4
*filter
Packit 7b22a4
:INPUT ACCEPT [5166:1752111]
Packit 7b22a4
:FORWARD ACCEPT [0:0]
Packit 7b22a4
:OUTPUT ACCEPT [5058:628693]
Packit 7b22a4
-A FORWARD -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
Packit 7b22a4
COMMIT
Packit 7b22a4
# Completed on Sat Dec 24 14:26:40 2016
Packit 7b22a4
Packit 7b22a4
root@machine:~# iptables-restore-translate -f save.txt
Packit 7b22a4
# Translated by iptables-restore-translate v1.6.0 on Sat Dec 24 14:26:59 2016
Packit 7b22a4
add table ip filter
Packit 7b22a4
add chain ip filter INPUT { type filter hook input priority 0; }
Packit 7b22a4
add chain ip filter FORWARD { type filter hook forward priority 0; }
Packit 7b22a4
add chain ip filter OUTPUT { type filter hook output priority 0; }
Packit 7b22a4
add rule ip filter FORWARD tcp dport 22 ct state new counter accept
Packit 7b22a4
Packit 7b22a4
root@machine:~# iptables-restore-translate -f save.txt > ruleset.nft
Packit 7b22a4
root@machine:~# nft -f ruleset.nft
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
		tcp dport ssh ct state new counter packets 0 bytes 0 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
Packit 7b22a4
.SH LIMITATIONS
Packit 7b22a4
Some (few) extensions may be not supported (or fully-supported) for whatever
Packit 7b22a4
reason (for example, they were considered obsolete, or we didn't have the time
Packit 7b22a4
to work on them).
Packit 7b22a4
Packit 7b22a4
There are no translations available for \fBebtables(8)\fP and
Packit 7b22a4
\fBarptables(8)\fP.
Packit 7b22a4
Packit 7b22a4
To get up-to-date information about this, please head to
Packit 7b22a4
\fBhttps://wiki.nftables.org/\fP.
Packit 7b22a4
Packit 7b22a4
.SH SEE ALSO
Packit 7b22a4
\fBnft(8)\fP, \fBiptables(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@netfilter.org>.
Packit 7b22a4
Packit 7b22a4
This documentation is free/libre under the terms of the GPLv2+.