From: Josh Cepek <josh.cepek@usa.net>
To: netfilter@vger.kernel.org
Subject: Re: DNAT multiple --to-destination gone: why?
Date: Thu, 10 Jul 2008 00:52:56 -0500 [thread overview]
Message-ID: <4875A3B8.9030602@usa.net> (raw)
In-Reply-To: <4875A076.5090907@riverviewtech.net>
[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]
Grant Taylor wrote:
> On 07/10/08 00:13, Josh Cepek wrote:
>
>> This is conceptually the same (but simpler than) the following series
>> of rules:
>> iptables -A PREROUTING -t nat -m statistic --mode nth --every 4 -j
>> DNAT 10.0.0.101
>> iptables -A PREROUTING -t nat -m statistic --mode nth --every 3 -j
>> DNAT 10.0.0.102
>> iptables -A PREROUTING -t nat -m statistic --mode nth --every 2 -j
>> DNAT 10.0.0.104
>> iptables -A PREROUTING -t nat -j DNAT 10.0.0.105
>>
>> Of course, you can continue to add more rules as required.
>
> Ugh. That does not scale very well at all. If you want to remove 102
> from above, you would have to re-write all the rules above it.
Quite right, and I don't suggest anyone use the above ruleset as it was
included to illustrate the process more clearly by using consecutive
statistic matches. The hint was that the concept could be expanded upon
as needed, such as the following example where $N is the number of
ranges needed:
-m statistic --mode nth --every $N -j DNAT $RANGE1
-m statistic --mode nth --every $(($N-1) -j DNAT $RANGE2
...
-m statistic --mode nth --every 2 -j DNAT $RANGE_N-1
-j DNAT $RANGE_N
Rather than introduce a new idea I just kept the IP data provided by the
OP. (And yes, for the terribly picky I know that doing this with uneven
ranges complicates things further, but I'm pretty sure someone wanting
this can read all about the --mode random functionality.)
--
Josh
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-07-10 5:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 0:32 DNAT multiple --to-destination gone: why? David Sparks
2008-07-10 5:13 ` Josh Cepek
2008-07-10 5:39 ` Grant Taylor
2008-07-10 5:52 ` Josh Cepek [this message]
2008-07-10 10:03 ` Jan Engelhardt
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=4875A3B8.9030602@usa.net \
--to=josh.cepek@usa.net \
--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 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.