Linux Netfilter discussions
 help / color / mirror / Atom feed
* track bandwith used
@ 2004-06-30 13:07 Peter Marshall
  2004-06-30 13:41 ` Antony Stone
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Marshall @ 2004-06-30 13:07 UTC (permalink / raw)
  To: netfilter

Hi again,

I was also wondering if anyone knows a way to track bandwith being used
through the firewall .......
I use squid as a proxy behind the firewall if that helps at all ...

Thank you again,
Peter




^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: track bandwith used
@ 2004-06-30 13:32 Piszcz, Justin Michael
  0 siblings, 0 replies; 12+ messages in thread
From: Piszcz, Justin Michael @ 2004-06-30 13:32 UTC (permalink / raw)
  To: Peter Marshall, netfilter

There are a plethora of ways to do this:

You can setup rules to watch the amount of bytes going through them
using ipacct w/iptables(1), or use something else, like my favorite,
vnstat.

MRTGFE (front-end) can also calculate bandwidth from MRTG's logs,
although it will not be as accurate as using vnstat or iptables rules.

Examples provided below:

$ vnstat-eth1
Database updated: Wed Jun 30 09:30:01 2004

        eth1

           received:         10,232 MB (68.0%)
        transmitted:          4,819 MB (32.0%)
              total:         15,052 MB

                        rx     |     tx     |  total
        -----------------------+------------+-----------
        yesterday    109.39 MB |   92.08 MB |  201.47 MB
            today     44.30 MB |   42.55 MB |   86.86 MB
        -----------------------+------------+-----------
        estimated       110 MB |     105 MB |     215 MB

$ vnstat-eth1 -m

        eth1

           month        rx      |       tx      |    total
        ------------------------+---------------+---------------
          Mar '04    628.07 MB  |    298.45 MB  |    926.52 MB
          Apr '04     3,793 MB  |     1,189 MB  |     4,982 MB
          May '04     3,243 MB  |     1,916 MB  |     5,159 MB
          Jun '04     2,568 MB  |     1,415 MB  |     3,983 MB
        ------------------------+---------------+---------------
        estimated     2,622 MB  |     1,445 MB  |     4,067 MB

$ vnstat-eth1 -d

        eth1

            day         rx      |     tx      |  total
        ------------------------+-------------+--------------
           01.06.    113.69 MB  |   55.42 MB  |  169.12 MB
           02.06.    113.55 MB  |   54.73 MB  |  168.28 MB
           03.06.    130.42 MB  |   53.92 MB  |  184.35 MB
           04.06.    121.90 MB  |   51.18 MB  |  173.08 MB
           05.06.    109.29 MB  |   17.41 MB  |  126.70 MB
           06.06.    132.68 MB  |   14.20 MB  |  146.89 MB
           07.06.     82.54 MB  |   42.67 MB  |  125.22 MB
           08.06.     97.28 MB  |   63.38 MB  |  160.67 MB
           09.06.     95.96 MB  |   65.29 MB  |  161.25 MB
           10.06.    101.92 MB  |   74.46 MB  |  176.38 MB
           11.06.    123.68 MB  |  109.23 MB  |  232.91 MB
           12.06.     82.51 MB  |   47.83 MB  |  130.34 MB
           13.06.     49.64 MB  |    9.30 MB  |   58.94 MB
           14.06.     83.63 MB  |   48.73 MB  |  132.36 MB
           15.06.     64.12 MB  |   30.81 MB  |   94.93 MB
           16.06.     68.01 MB  |   47.18 MB  |  115.20 MB
           17.06.     69.38 MB  |   41.79 MB  |  111.17 MB
           18.06.     63.69 MB  |   27.17 MB  |   90.86 MB
           19.06.     51.91 MB  |   10.50 MB  |   62.42 MB
           20.06.     53.63 MB  |   10.54 MB  |   64.18 MB
           21.06.     84.77 MB  |   60.95 MB  |  145.72 MB
           22.06.     83.01 MB  |   60.98 MB  |     144 MB
           23.06.     49.68 MB  |   57.53 MB  |  107.22 MB
           24.06.     95.58 MB  |   79.03 MB  |  174.61 MB
           25.06.     92.69 MB  |   70.15 MB  |  162.85 MB
           26.06.     64.53 MB  |   12.19 MB  |   76.72 MB
           27.06.     54.97 MB  |   11.99 MB  |   66.96 MB
           28.06.     79.98 MB  |   52.11 MB  |  132.10 MB
           29.06.    109.39 MB  |   92.08 MB  |  201.47 MB
           30.06.     44.30 MB  |   42.55 MB  |   86.86 MB
        ------------------------+-------------+--------------
         estimated      110 MB  |     105 MB  |     215 MB



-----Original Message-----
From: netfilter-admin@lists.netfilter.org
[mailto:netfilter-admin@lists.netfilter.org] On Behalf Of Peter Marshall
Sent: Wednesday, June 30, 2004 9:07 AM
To: netfilter
Subject: track bandwith used

Hi again,

I was also wondering if anyone knows a way to track bandwith being used
through the firewall .......
I use squid as a proxy behind the firewall if that helps at all ...

Thank you again,
Peter





^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: track bandwith used
@ 2004-06-30 14:07 Aldo Lagana
  0 siblings, 0 replies; 12+ messages in thread
From: Aldo Lagana @ 2004-06-30 14:07 UTC (permalink / raw)
  To: netfilter

iptraf 

-----Original Message-----
From: Antony Stone [mailto:Antony@Soft-Solutions.co.uk]
Sent: Wednesday, June 30, 2004 9:41 AM
To: netfilter
Subject: Re: track bandwith used


On Wednesday 30 June 2004 2:07 pm, Peter Marshall wrote:

> Hi again,
>
> I was also wondering if anyone knows a way to track bandwith being used
> through the firewall .......

Well, there are plenty of network monitoring tools which will give you this 
sort of information as an aggregate figure for an interface, or broken down 
by source/destination address, port number etc - iptraf is not a bad start to 
see what can be done.

Other than that you can use netfilter rules to count the packets & bytes, and 
then use a cron job to record the counts at whatever intervals you want 
(every minute, every hour, every day...), and then process them yourself.

Things I would mention if you're going to try the latter option:

1. Most packets do not match against rules in the nat table, so don't try 
counting those - the only packets which match these are the first of each 
connection - all the rest are processed invisibly by netfilter in the 
background, and your rules don't see them (this is also the reason why you 
should never set a default DROP policy on a nat table!)

2. If you are using a standard -m state --state ESTABLISHED,RELATED rule in 
your FORWARD chain, remember that nearly all packets will match that, no 
matter which direction they're going through the machine, and which port/s 
they're going to or from.   Again, most of the rules in your FORWARD chain 
will only match the first packet of a given connection, so you won't see much 
traffic on these rules either (although they can give you a useful indication 
of the number of connections of that type which get created).

3. The FORWARD mangle table can be a good place to put rules which will see 
all traffic going through the system.

4. For accounting purposes, you can quite readily use rules with no target 
(eg: iptables -A FORWARD -p tcp --dport 25); these will make no difference to 
whether the packets are ACCEPTed, DROPped, LOGged, REJECTed, or whatever 
(obviously you need separate rules to do that somewhere else), but the packet 
& byte counters from iptables -L -nvx will show you how many of that type of 
packet were seen.   You can make the rules as specific as you like if you 
want to count certain connections in minute detail (eg: iptables -A FORWARD 
-p tcp --dport 25 -s my.mail.ser.ver -d ISP.mail.ser.ver)

5. Don't overlook the raw packet & byte counts available from ifconfig if all 
you want to do is monitor traffic in & out of an interface.

Hope this give you some ideas.

Regards,

Antony.

-- 
"The future is already here.   It's just not evenly distributed yet."

 - William Gibson

                                                     Please reply to the list;
                                                           please don't CC me.



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: track bandwith used
@ 2004-06-30 16:55 Antony Stone
  0 siblings, 0 replies; 12+ messages in thread
From: Antony Stone @ 2004-06-30 16:55 UTC (permalink / raw)
  To: netfilter

On Wednesday 30 June 2004 2:07 pm, Peter Marshall wrote:

> Hi again,
>
> I was also wondering if anyone knows a way to track bandwith being used
> through the firewall .......

Well, there are plenty of network monitoring tools which will give you this 
sort of information as an aggregate figure for an interface, or broken down 
by source/destination address, port number etc - iptraf is not a bad start to 
see what can be done.

Other than that you can use netfilter rules to count the packets & bytes, and 
then use a cron job to record the counts at whatever intervals you want 
(every minute, every hour, every day...), and then process them yourself.

Things I would mention if you're going to try the latter option:

1. Most packets do not match against rules in the nat table, so don't try 
counting those - the only packets which match these are the first of each 
connection - all the rest are processed invisibly by netfilter in the 
background, and your rules don't see them (this is also the reason why you 
should never set a default DROP policy on a nat table!)

2. If you are using a standard -m state --state ESTABLISHED,RELATED rule in 
your FORWARD chain, remember that nearly all packets will match that, no 
matter which direction they're going through the machine, and which port/s 
they're going to or from.   Again, most of the rules in your FORWARD chain 
will only match the first packet of a given connection, so you won't see much 
traffic on these rules either (although they can give you a useful indication 
of the number of connections of that type which get created).

3. The FORWARD mangle table can be a good place to put rules which will see 
all traffic going through the system.

4. For accounting purposes, you can quite readily use rules with no target 
(eg: iptables -A FORWARD -p tcp --dport 25); these will make no difference to 
whether the packets are ACCEPTed, DROPped, LOGged, REJECTed, or whatever 
(obviously you need separate rules to do that somewhere else), but the packet 
& byte counters from iptables -L -nvx will show you how many of that type of 
packet were seen.   You can make the rules as specific as you like if you 
want to count certain connections in minute detail (eg: iptables -A FORWARD 
-p tcp --dport 25 -s my.mail.ser.ver -d ISP.mail.ser.ver)

5. Don't overlook the raw packet & byte counts available from ifconfig if all 
you want to do is monitor traffic in & out of an interface.

Hope this give you some ideas.

Regards,

Antony.

-- 
"The future is already here.   It's just not evenly distributed yet."

 - William Gibson

                                                     Please reply to the list;
                                                           please don't CC me.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-07-01  7:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-30 13:07 track bandwith used Peter Marshall
2004-06-30 13:41 ` Antony Stone
2004-06-30 14:07   ` Peter Marshall
2004-06-30 16:17     ` Antony Stone
2004-06-30 16:51       ` Peter Marshall
2004-06-30 17:07         ` Antony Stone
2004-06-30 18:46           ` Peter Marshall
2004-06-30 22:03             ` Antony Stone
2004-07-01  7:01               ` Askar Ali Khan
  -- strict thread matches above, loose matches on Subject: below --
2004-06-30 13:32 Piszcz, Justin Michael
2004-06-30 14:07 Aldo Lagana
2004-06-30 16:55 Antony Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox