Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@vger.kernel.org
Subject: Re: SNAT with ip address range not working...
Date: Tue, 18 Nov 2008 17:00:15 +0100	[thread overview]
Message-ID: <4922E68F.7020709@plouf.fr.eu.org> (raw)
In-Reply-To: <8FC72664318547708851AFDCFB7B1721@squarepi.com>

Hello,

John Lister a écrit :
> Hi, i'm trying to set up a rule to snat over a range of ip addresses with
> something like this:
> 
> iptables -t nat -A POSTROUTING -m state --state NEW -j SNAT --to-source 
> 192.168.96.34-192.168.96.136
> 
> however after dumping the packets, it seems that only the first address 
> is ever used and the rule is being matched correctly
> 
> In the docs it mentions that it selects an address in the range at 
> random for a stream - i'm assuming for netfilter a stream is a single 
> connection and each subsequent connection should get a new ip address, 
> or does it group similar connections to/from the same ip addresses and 
> give it the same ip address - which happens with routing (cache)?

Your documentation may be outdated. Since the linux kernel 2.6.11, 
randomness (actually round robin AFAIK) in the SNAT and DNAT address 
selection has been replaced with a selection based on a hash of the 
source and destination address. So for the same (src, dst) SNAT and DNAT 
will always select the same address in the range.

      reply	other threads:[~2008-11-18 16:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-18 14:50 SNAT with ip address range not working John Lister
2008-11-18 16:00 ` Pascal Hambourg [this message]

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=4922E68F.7020709@plouf.fr.eu.org \
    --to=pascal.mail@plouf.fr.eu.org \
    --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