(phil, please cut-n-paste this into the ipf FAQ when you
get a chance.  thanks bud.)


FAQ: How can i use "count" to count bytes?

First refer to the ipf(5) man page.  Under solaris at least,
$ man -s 5 ipf
will give you all the possible ipf.conf syntax expressions,
including proper usage of "count":
[...]
ACTIONS
  The action indicates what  to  do  with  the  packet  if  it
  matches  the rest of the filter rule. Each rule MUST have an
  action. The following actions are recognised:
[...]
  count
    causes the packet to  be  included  in  the  accounting
    statistics  kept  by  the  filter, and has no effect on
    whether the packet will be allowed through the  filter.
    These statistics are viewable with ipfstat(8).
[...]

Thus, with "count" directives in your ruleset, such as
those shown in the snippet below, you can get the current
byte counts by "ipfstat -c" as such (for both in and out):

<portion of ipf.conf shown>
# ip packet counting rules:
#
# !total traffic routed from/to the world!
count in  on iprb0 from any to any
count out on iprb0 from any to any
#
# !total traffic from/to the firewall itself!
count in  on iprb0 from any to your.ip.104.61/32
count out on iprb0 from your.ip.104.61/32 to any
# eof

$ ipfstat -aio
6360 count out on iprb0 from any to any
6492 count out on iprb0 from my.ip.104.61/32 to any
7404 count in on iprb0 from any to any
7404 count in on iprb0 from any to my.ip.104.61/32

You can "reset" the byte counters to zero at anytime with:
$ /sbin/ipf -Fa -f /etc/opt/ipf/ipf.conf

For more info on count, try this search:
  http://marc.theaimsgroup.com/?l=ipfilter&w=2&r=1&s=count&q=b
And some for trivial examples, look here:
  http://marc.theaimsgroup.com/?l=ipfilter&m=97562112311937&w=2

Of course, it is immediately obvious that "count" directives
used in conjunction with mrtg/rrdtool and some shell scripts
can be used to graph traffic, prepare hourly/daily/monthly
byte reports, etc. This is left as an exercise to the reader;
but, since you asked nicely, there are some scripts available
which may aid report/graph generation.  See, for example,
http://www2.empnet.com/ipacct/
http://ipaudit.sourceforge.net/ (not ipf-specific)
http://ojnk.sourceforge.net/ (not ipf-specific)
http://www2.auckland.ac.nz/net/NeTraMet/ (not ipf-specific)


ps and n.b.
you'll note that my ruleset uses "!description!" fields,
i use a modified version of ipacct to make summary tables,
and those description fields are used in the header of the
tables.

jim



Vedran Bender wrote:

-----Original Message-----
From: Jim Sandoz [mailto:[EMAIL PROTECTED]]

#
# ip packet counting rulesets:
#
# !total traffic routed from/to the world!
count in  on iprb0 from any to any
count out on iprb0 from any to any
#
# !total traffic from/to the firewall itself!
count in  on iprb0 from any to your.ip.104.61/32
count out on iprb0 from your.ip.104.61/32 to any

I don't remember the count directive when reading the documentation that Mr.
Dibowitz wrote (I may have missed it, admittedly). How does it work, or do
I need to go back and RTFM?

Reply via email to