netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [PATCH nftables 7/8] doc: add shifted port-ranges to nat statements
Date: Sun,  5 Mar 2023 10:14:17 +0000	[thread overview]
Message-ID: <20230305101418.2233910-8-jeremy@azazel.net> (raw)
In-Reply-To: <20230305101418.2233910-1-jeremy@azazel.net>

Extend the description of ports to cover ranges and shifted ranges, and
add an example of the latter.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 doc/statements.txt | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/statements.txt b/doc/statements.txt
index b2794bcd6821..3dd3b98b6cb1 100644
--- a/doc/statements.txt
+++ b/doc/statements.txt
@@ -362,7 +362,7 @@ ____
 *redirect* [*to :*'PORT_SPEC'] ['FLAGS']
 
 'ADDR_SPEC' := 'address' | 'address' *-* 'address'
-'PORT_SPEC' := 'port' | 'port' *-* 'port'
+'PORT_SPEC' := 'port' | 'port' *-* 'port' | 'port' *-* 'port' */* 'port'
 
 'FLAGS'  := 'FLAG' [*,* 'FLAGS']
 'FLAG'  := *persistent* | *random* | *fully-random*
@@ -405,7 +405,10 @@ You may specify a mapping to relate a list of tuples composed of arbitrary
 expression key with address value. |
 ipv4_addr, ipv6_addr, e.g. abcd::1234, or you can use a mapping, e.g. meta mark map { 10 : 192.168.1.2, 20 : 192.168.1.3 }
 |port|
-Specifies that the source/destination port of the packet should be modified. |
+Specifies that the source/destination port of the packet should be modified.  If
+a range is given, the new port will be chosen from within that range.  If a base
+offset is also given, the offset of the new port in the range will match the
+offset of the old port from the specified base.|
 port number (16 bit)
 |===============================
 
@@ -437,6 +440,10 @@ add rule nat postrouting oif eth0 snat to 1.2.3.4
 # redirect all traffic entering via eth0 to destination address 192.168.1.120
 add rule nat prerouting iif eth0 dnat to 192.168.1.120
 
+# redirect all traffic for address 10.0.0.1 and ports 2000-3000 to destination
+# address 10.10.0.1 and the port at the matching offset in 12000-13000
+add rule nat prerouting ip daddr 10.0.0.1 tcp dport 2000-3000 dnat to 10.10.0.1:12000-13000/2000
+
 # translate source addresses of all packets leaving via eth0 to whatever
 # locally generated packets would use as source to reach the same destination
 add rule nat postrouting oif eth0 masquerade
-- 
2.39.2


  parent reply	other threads:[~2023-03-05 10:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-05 10:14 [PATCH nftables 0/8] Support for shifted port-ranges in NAT Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 1/8] nat: add support for shifted port-ranges Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 2/8] masq: " Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 3/8] redir: " Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 4/8] json: formatting fixes Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 5/8] json: add support for shifted nat port-ranges Jeremy Sowden
2023-03-05 10:14 ` [PATCH nftables 6/8] doc: correct NAT statement description Jeremy Sowden
2023-03-05 10:14 ` Jeremy Sowden [this message]
2023-03-05 10:14 ` [PATCH nftables 8/8] test: py: add tests for shifted nat port-ranges Jeremy Sowden
2023-03-24 22:59   ` Florian Westphal
2023-03-25 10:35     ` Phil Sutter
2023-03-25 11:10       ` Jeremy Sowden
2023-03-26 20:41         ` Pablo Neira Ayuso
2023-03-26 20:39     ` Pablo Neira Ayuso
2023-03-27 11:08       ` Jeremy Sowden
2023-04-11 12:21       ` Jeremy Sowden
2023-04-12 11:06         ` Pablo Neira Ayuso
2023-04-25 19:51           ` Jeremy Sowden
2023-05-03 20:54             ` Pablo Neira Ayuso
2023-05-08 17:58               ` Jeremy Sowden
2023-05-08 19:47                 ` Pablo Neira Ayuso
2023-04-11  8:28     ` Pablo Neira Ayuso
2023-04-11 10:25       ` Florian Westphal
2023-04-11 10:53         ` Pablo Neira Ayuso
2023-04-11 11:20           ` Florian Westphal
2023-04-11 11:43             ` Pablo Neira Ayuso
2023-04-11 12:28               ` Florian Westphal
2023-04-11 12:36       ` Florian Westphal
2023-04-12 11:22         ` Pablo Neira Ayuso
2023-04-12 11:43           ` Florian Westphal
2023-04-12 12:54             ` Pablo Neira Ayuso
2023-03-24 14:18 ` [PATCH nftables 0/8] Support for shifted port-ranges in NAT Florian Westphal
2023-03-24 16:07   ` Jeremy Sowden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230305101418.2233910-8-jeremy@azazel.net \
    --to=jeremy@azazel.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).