|
 |
ad45ff |
From 3344672e56bad6468981d1bf683c312b18957671 Mon Sep 17 00:00:00 2001
|
|
 |
ad45ff |
From: Phil Sutter <psutter@redhat.com>
|
|
 |
ad45ff |
Date: Thu, 4 Apr 2019 13:02:55 +0200
|
|
 |
ad45ff |
Subject: [PATCH] doc: Add minimal description of (v)map statements
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1628974
|
|
 |
ad45ff |
Upstream Status: nftables commit 3b29acc8f2994
|
|
 |
ad45ff |
Conflicts: Changes applied manually to doc/nft.xml, upstream switched to
|
|
 |
ad45ff |
using asciidoc.
|
|
 |
ad45ff |
|
|
 |
ad45ff |
commit 3b29acc8f29944c5cf34259f2e2b5b40b4d0ccdd
|
|
 |
ad45ff |
Author: Phil Sutter <phil@nwl.cc>
|
|
 |
ad45ff |
Date: Tue Apr 2 15:36:42 2019 +0200
|
|
 |
ad45ff |
|
|
 |
ad45ff |
doc: Add minimal description of (v)map statements
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Although quite useful, these were missing in man page. Content loosely
|
|
 |
ad45ff |
based on wiki documentation.
|
|
 |
ad45ff |
|
|
 |
ad45ff |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
 |
ad45ff |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
 |
ad45ff |
---
|
|
 |
ad45ff |
doc/nft.xml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
 |
ad45ff |
1 file changed, 65 insertions(+)
|
|
 |
ad45ff |
|
|
 |
ad45ff |
diff --git a/doc/nft.xml b/doc/nft.xml
|
|
 |
ad45ff |
index 12b6cea..5ab363f 100644
|
|
 |
ad45ff |
--- a/doc/nft.xml
|
|
 |
ad45ff |
+++ b/doc/nft.xml
|
|
 |
ad45ff |
@@ -5012,6 +5012,71 @@ add rule nat prerouting tcp dport 22 redirect to :2222
|
|
 |
ad45ff |
|
|
 |
ad45ff |
</para>
|
|
 |
ad45ff |
</refsect2>
|
|
 |
ad45ff |
+ <refsect2>
|
|
 |
ad45ff |
+ <title>Map statement</title>
|
|
 |
ad45ff |
+ <para>
|
|
 |
ad45ff |
+ The map statement is used to lookup data based on some specific input key.
|
|
 |
ad45ff |
+ </para>
|
|
 |
ad45ff |
+ <para>
|
|
 |
ad45ff |
+ <cmdsynopsis>
|
|
 |
ad45ff |
+ <replaceable>expression</replaceable>
|
|
 |
ad45ff |
+ <command>map {</command>
|
|
 |
ad45ff |
+ <replaceable>key</replaceable>
|
|
 |
ad45ff |
+ <command>:</command>
|
|
 |
ad45ff |
+ <replaceable>value</replaceable>
|
|
 |
ad45ff |
+ <arg choice="opt" rep="repeat">
|
|
 |
ad45ff |
+ <command>,</command>
|
|
 |
ad45ff |
+ <replaceable>key</replaceable>
|
|
 |
ad45ff |
+ <command>:</command>
|
|
 |
ad45ff |
+ <replaceable>value</replaceable>
|
|
 |
ad45ff |
+ </arg>
|
|
 |
ad45ff |
+ <command>}</command>
|
|
 |
ad45ff |
+ </cmdsynopsis>
|
|
 |
ad45ff |
+ </para>
|
|
 |
ad45ff |
+ <example>
|
|
 |
ad45ff |
+ <title>using the map statement</title>
|
|
 |
ad45ff |
+ <programlisting>
|
|
 |
ad45ff |
+# select DNAT target based on TCP dport:
|
|
 |
ad45ff |
+# connections to port 80 are redirected to 192.168.1.100,
|
|
 |
ad45ff |
+# connections to port 8888 are redirected to 192.168.1.101
|
|
 |
ad45ff |
+nft add rule ip nat prerouting dnat tcp dport map { 80 : 192.168.1.100, 8888 : 192.168.1.101 }
|
|
 |
ad45ff |
+
|
|
 |
ad45ff |
+# source address based SNAT:
|
|
 |
ad45ff |
+# packets from net 192.168.1.0/24 will appear as originating from 10.0.0.1,
|
|
 |
ad45ff |
+# packets from net 192.168.2.0/24 will appear as originating from 10.0.0.2
|
|
 |
ad45ff |
+nft add rule ip nat postrouting snat to ip saddr map { 192.168.1.0/24 : 10.0.0.1, 192.168.2.0/24 : 10.0.0.2 }
|
|
 |
ad45ff |
+ </programlisting>
|
|
 |
ad45ff |
+ </example>
|
|
 |
ad45ff |
+ </refsect2>
|
|
 |
ad45ff |
+ <refsect2>
|
|
 |
ad45ff |
+ <title>Vmap statement</title>
|
|
 |
ad45ff |
+ <para>
|
|
 |
ad45ff |
+ The verdict map (vmap) statement works analogous to the map statement, but contains verdicts as values.
|
|
 |
ad45ff |
+ </para>
|
|
 |
ad45ff |
+ <para>
|
|
 |
ad45ff |
+ <cmdsynopsis>
|
|
 |
ad45ff |
+ <replaceable>expression</replaceable>
|
|
 |
ad45ff |
+ <command>vmap {</command>
|
|
 |
ad45ff |
+ <replaceable>key</replaceable>
|
|
 |
ad45ff |
+ <command>:</command>
|
|
 |
ad45ff |
+ <replaceable>value</replaceable>
|
|
 |
ad45ff |
+ <arg choice="opt" rep="repeat">
|
|
 |
ad45ff |
+ <command>,</command>
|
|
 |
ad45ff |
+ <replaceable>key</replaceable>
|
|
 |
ad45ff |
+ <command>:</command>
|
|
 |
ad45ff |
+ <replaceable>value</replaceable>
|
|
 |
ad45ff |
+ </arg>
|
|
 |
ad45ff |
+ <command>}</command>
|
|
 |
ad45ff |
+ </cmdsynopsis>
|
|
 |
ad45ff |
+ </para>
|
|
 |
ad45ff |
+ <example>
|
|
 |
ad45ff |
+ <title>using the vmap statement</title>
|
|
 |
ad45ff |
+ <programlisting>
|
|
 |
ad45ff |
+# jump to different chains depending on layer 4 protocol type:
|
|
 |
ad45ff |
+nft add rule ip filter input ip protocol vmap { tcp : jump tcp-chain, udp : jump udp-chain , icmp : jump icmp-chain }
|
|
 |
ad45ff |
+ </programlisting>
|
|
 |
ad45ff |
+ </example>
|
|
 |
ad45ff |
+ </refsect2>
|
|
 |
ad45ff |
</refsect1>
|
|
 |
ad45ff |
|
|
 |
ad45ff |
<refsect1>
|
|
 |
ad45ff |
--
|
|
 |
ad45ff |
1.8.3.1
|
|
 |
ad45ff |
|