From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Joshua Moore <ridgebacktech@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Nftables src NAT with port range allocation
Date: Mon, 31 Aug 2020 17:36:44 +0200 [thread overview]
Message-ID: <20200831153643.GC2725@salvia> (raw)
In-Reply-To: <CAK+5afBrW7h=YQ5eCL0DfDguLd44Os=rwe-_1=xWVMaP8nHR9g@mail.gmail.com>
On Thu, Aug 27, 2020 at 06:02:58PM -0500, Joshua Moore wrote:
> Hello,
>
> I am wanting to do a determinate src NAT IP/port range allocation
> leveraging nftables. For example, for every "original src
> address:original src port" there is a mapped "new src address:new src
> port". The original source address is known but the original source
> port is unknown. The new src address is known and the new src port is
> from a known range or ports.
>
> I thought about leveraging maps to do this but I'm unsure of the best
> way to dynamically capture the unknown src address. Any suggestions?
table ip nat {
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
dnat ip addr . port to ip saddr . th dport map { 2.2.2.2 . 80 : 3.3.3.3 . 443 }
}
}
This is mapping:
IP saddr th dport IP daddr dport
2.2.2.2 . 80 -> 3.3.3.3 443
IIRC, this is available since nft 0.9.4, I'm testing with current git
snapshot.
next prev parent reply other threads:[~2020-08-31 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 23:02 Nftables src NAT with port range allocation Joshua Moore
2020-08-31 15:36 ` Pablo Neira Ayuso [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-27 22:57 Joshua Moore
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=20200831153643.GC2725@salvia \
--to=pablo@netfilter.org \
--cc=netfilter@vger.kernel.org \
--cc=ridgebacktech@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.