From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo@debian.org>
Cc: Zheng konia <konianet@gmail.com>,
Netfilter Users Mailing list <netfilter@vger.kernel.org>
Subject: Re: About nftable nat rule
Date: Wed, 24 May 2017 12:44:46 +0200 [thread overview]
Message-ID: <20170524104446.GA23302@salvia> (raw)
In-Reply-To: <CAOkSjBiuGUkVirqtAbCSPQd5pwvMcjgvt6FPApUaAgU2eXZ7Bg@mail.gmail.com>
On Wed, May 24, 2017 at 11:49:04AM +0200, Arturo Borrero Gonzalez wrote:
> On 24 May 2017 at 11:30, Zheng konia <konianet@gmail.com> wrote:
> > Hi, I do have read your wiki.
> >
> > However, there's less example about DNAT --to-destination-port range.
> > You do have examples about to different destination, while I am
> > looking for the different destination-port balance.
> >
> > Any suggestion?
> >
>
> Try something like this:
>
> nft add rule t c ip protocol tcp dnat to 192.168.1.100 : numgen inc
> mod 2 map { 0 : 4040 , 1 : 4050 }
> (i.e, the destination address doesn't change, but port does)
>
> We can update the wiki if that works.
BTW, depending on your environment, you may want to use a stateless
NAT approach too that should be faster, eg.
nft add rule t c ip protocol ip daddr set 192.168.1.100 \
tcp dport set numgen inc mod 2 map { 0 : 4040 , 1 : 4050 }
This requires a recent Linux kernel though.
Note: Beware with stateless NAT, it only works with 1:1 mappings, it's
easy to shoot yourself on your own feet... Otherwise, stick to the
stateful approach.
next prev parent reply other threads:[~2017-05-24 10:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 8:40 About nftable nat rule Zheng konia
2017-05-24 9:07 ` Arturo Borrero Gonzalez
2017-05-24 9:30 ` Zheng konia
2017-05-24 9:49 ` Arturo Borrero Gonzalez
2017-05-24 10:44 ` Pablo Neira Ayuso [this message]
2017-05-24 11:34 ` Arturo Borrero Gonzalez
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=20170524104446.GA23302@salvia \
--to=pablo@netfilter.org \
--cc=arturo@debian.org \
--cc=konianet@gmail.com \
--cc=netfilter@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