Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
To: "Nestor A. Diaz" <nestor@tiendalinux.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Clarification on the use of the statistic module
Date: Thu, 11 Jul 2013 11:10:47 +0200	[thread overview]
Message-ID: <51DE7697.3020204@plouf.fr.eu.org> (raw)
In-Reply-To: <51DD79C7.3080707@tiendalinux.com>

Hello,

Nestor A. Diaz a écrit :
> 
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -m statistic --mode nth --every 2 --packet 0 -j LOG
> --log-prefix 20130710095901_packet_0
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -m statistic --mode nth --every 2 --packet 0 -j ACCEPT
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -m statistic --mode nth --every 2 --packet 1 -j LOG
> --log-prefix 20130710095901_packet_1
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -m statistic --mode nth --every 2 --packet 1 -j ACCEPT
> # default
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -j LOG --log-prefix 20130710095901_packet_2
> /sbin/iptables -t nat -A prerouting_rule -i eth0 -p tcp --dport 7000 -m
> state --state NEW -j ACCEPT

Note : the state match is useless here : by definition packets in the
nat table cannot have any other state than NEW.

> ./count_packets.sh 20130710093659
> 0: 500
> 1: 250
> 2: 250

Exactly as expected.

> When i was expecting the following result:
> 
> 0: 500
> 1: 500
> 2: 0
> 
> What i am doing wrong ?

You ACCEPT the packets matching the first statistic set, so they won't
reach the second one. Therefore the second statistic set matches 50% of
the remaining packets, i.e. 50% * 50% = 25%.

  reply	other threads:[~2013-07-11  9:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 15:12 Clarification on the use of the statistic module Nestor A. Diaz
2013-07-11  9:10 ` Pascal Hambourg [this message]
2013-07-11 18:49   ` Nestor A. Diaz
2013-07-11 23:15     ` Pascal Hambourg
2013-07-12 16:55       ` Nestor A. Diaz
2013-07-12  6:37     ` Emilio Lazo Zaia

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=51DE7697.3020204@plouf.fr.eu.org \
    --to=pascal@plouf.fr.eu.org \
    --cc=nestor@tiendalinux.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