Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Martijn Lievaart <m@rtij.nl>
To: Kamal <kamash@gmail.com>
Cc: netfilter@lists.netfilter.org
Subject: Re: NAT POSTROUTING accounting
Date: Sun, 15 Oct 2006 20:09:43 +0200	[thread overview]
Message-ID: <45327967.8080406@rtij.nl> (raw)
In-Reply-To: <8a1be4700610150743t6c089bfcm7648174d88793c00@mail.gmail.com>

Kamal wrote:

> I have the following 2 rules:
> iptables -t nat -I POSTROUTING -o eth0 -p tcp --dport 80 -j SNAT --to
> 192.168.0.1
> iptables -t nat -I POSTROUTING -o eth0 -j SNAT --to  192.168.0.2
>
> How can I do accounting on TOTAL number of packets & bytes that pass
> through both rules since the packets & bytes that appear when listing
> the chain reflect the number of packets creating new connections & not
> all the packets that are NAT'ed. Also you can't add a chain in front
> of this chain since NAT POSTROUTING is the last chain in a packet
> traversal:
>
> Chain POSTROUTING (policy ACCEPT 2593 packets, 1181K bytes)
>  pkts bytes target     prot opt in     out     source               
> destination
>  2259  114K SNAT       tcp  --  *      eth0     0.0.0.0/0
> 0.0.0.0/0           tcp dpt:80 to:192.168.0.1
>  223K   15M SNAT       all  --  *      eth0    0.0.0.0/0
> 0.0.0.0/0           to:192.168.0.2
>

Create a seperate rule in FORWARD that jumps to an empty chain. Put this 
rule before the -m state rule(s).

HTH,
M4



  reply	other threads:[~2006-10-15 18:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-15 14:43 NAT POSTROUTING accounting Kamal
2006-10-15 18:09 ` Martijn Lievaart [this message]
2006-10-16 12:00   ` Kamal
2006-10-16 12:28     ` Gáspár Lajos
2006-10-16 13:22       ` Kamal
2006-10-16 14:03         ` Gáspár Lajos
2006-10-16 17:40           ` Kamal

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=45327967.8080406@rtij.nl \
    --to=m@rtij.nl \
    --cc=kamash@gmail.com \
    --cc=netfilter@lists.netfilter.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