Linux Netfilter discussions
 help / color / mirror / Atom feed
From: John Lister <john.lister@kickstone.com>
To: Kirk Hoganson <kirkhoganson@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Round Robin or Random Source NATing
Date: Tue, 22 Feb 2011 23:50:52 +0000	[thread overview]
Message-ID: <4D644BDC.1020107@kickstone.com> (raw)
In-Reply-To: <4D642A6B.4050806@gmail.com>

On 22/02/2011 21:28, Kirk Hoganson wrote:
> I am attempting to create a series of rules that source nat web 
> traffic amongst a pool of IP addresses.  I have used the nth mode to 
> cycle through the IP address in a round robin fashion.  I am using the 
> following rules:
>
> $IPTABLES -t nat -A POSTROUTING -o $EXT -m state --state NEW -p tcp -m 
> multiport --dport 80,443 -m statistic --mode nth --every 24 --packet 0 
> -j SNAT --to-source 1.104.126.216
Beware that the statistic module counts apply PER rule and not to some 
global counter as they used to in earlier versions - this caught me out 
before. So with your case, the first rule is matched every 24 packets, 
but the second one is matched every 24 packets NOT matched by the 
earlier rule, and so on. So any default in your case is much more likely 
to happen than you expect.
try doing something like:
$IPTABLES -t nat -A POSTROUTING -o $EXT -m state --state NEW -p tcp -m 
multiport --dport 80,443 -m statistic --mode nth --every 24 --packet 0 
-j SNAT --to-source 1.104.126.x
$IPTABLES -t nat -A POSTROUTING -o $EXT -m state --state NEW -p tcp -m 
multiport --dport 80,443 -m statistic --mode nth --every 23 --packet 0 
-j SNAT --to-source 1.104.126.x
$IPTABLES -t nat -A POSTROUTING -o $EXT -m state --state NEW -p tcp -m 
multiport --dport 80,443 -m statistic --mode nth --every 22 --packet 0 
-j SNAT --to-source 1.104.126.x


The same applies with random, you need to reduce the probability based 
on the chance of it being hit, eg:
.25, .33, .50, 1

  reply	other threads:[~2011-02-22 23:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 21:28 Round Robin or Random Source NATing Kirk Hoganson
2011-02-22 23:50 ` John Lister [this message]
2011-02-23 18:43   ` Kirk Hoganson
2011-02-24 23:03     ` Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2011-02-18  6:38 Kirk Hoganson

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=4D644BDC.1020107@kickstone.com \
    --to=john.lister@kickstone.com \
    --cc=kirkhoganson@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