path: root/iptables/
diff options
authorPablo Neira Ayuso <>2014-04-11 12:31:39 +0200
committerPablo Neira Ayuso <>2016-02-16 19:30:21 +0100
commit933400b37d0966980d07d32b64403830429761ed (patch)
treea2540049b9e8c1d679bc2d8a096f0ffc629b9d36 /iptables/
parentd13b60c9ddb48e651b92f13579e236c530658176 (diff)
nft: xtables: add the infrastructure to translate from iptables to nft
This patch provides the infrastructure and two new utilities to translate iptables commands to nft, they are: 1) iptables-restore-translate which basically takes a file that contains the ruleset in iptables-restore format and converts it to the nft syntax, eg. % iptables-restore-translate -f ipt-ruleset > nft-ruleset % cat nft-ruleset # Translated by iptables-restore-translate v1.4.21 on Mon Apr 14 12:18:14 2014 add table ip filter add chain ip filter INPUT { type filter hook input priority 0; } add chain ip filter FORWARD { type filter hook forward priority 0; } add chain ip filter OUTPUT { type filter hook output priority 0; } add rule ip filter INPUT iifname lo counter accept # -t filter -A INPUT -m state --state INVALID -j LOG --log-prefix invalid: ... The rules that cannot be translated are left commented. Users should be able to run this to track down the nft progress to see at what point it can fully replace iptables and their filtering policy. 2) iptables-translate which suggests a translation for an iptables command: $ iptables-translate -I OUTPUT -p udp -d -j ACCEPT nft add rule filter OUTPUT ip protocol udp ip dst counter accept Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'iptables/')
1 files changed, 4 insertions, 1 deletions
diff --git a/iptables/ b/iptables/
index c3eb8a81..569a739d 100644
--- a/iptables/
+++ b/iptables/
@@ -43,7 +43,8 @@ xtables_compat_multi_SOURCES += xtables-save.c xtables-restore.c \
nft-shared.c nft-ipv4.c nft-ipv6.c nft-arp.c \
xtables-arp-standalone.c xtables-arp.c \
getethertype.c nft-bridge.c \
- xtables-eb-standalone.c xtables-eb.c
+ xtables-eb-standalone.c xtables-eb.c \
+ xtables-translate.c
xtables_compat_multi_LDADD += ${libmnl_LIBS} ${libnftnl_LIBS} ${libnetfilter_conntrack_LIBS} ../extensions/libext4.a ../extensions/libext6.a ../extensions/libext_ebt.a ../extensions/libext_arpt.a
# yacc and lex generate dirty code
xtables_compat_multi-xtables-config-parser.o xtables_compat_multi-xtables-config-syntax.o: AM_CFLAGS += -Wno-missing-prototypes -Wno-missing-declarations -Wno-implicit-function-declaration -Wno-nested-externs -Wno-undef -Wno-redundant-decls
@@ -71,6 +72,8 @@ endif
x_sbin_links = iptables-compat iptables-compat-restore iptables-compat-save \
ip6tables-compat ip6tables-compat-restore ip6tables-compat-save \
+ iptables-translate ip6tables-translate \
+ iptables-restore-translate ip6tables-restore-translate \
arptables-compat ebtables-compat