<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>freebsd.munk.me.uk - IPFW</title>
    <link>http://freebsd.munk.me.uk/</link>
    <description>FreeBSD System Administration</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://freebsd.munk.me.uk/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: freebsd.munk.me.uk - IPFW - FreeBSD System Administration</title>
        <link>http://freebsd.munk.me.uk/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>IPFWstats SourceForge Project</title>
    <link>http://freebsd.munk.me.uk/archives/13-IPFWstats-SourceForge-Project.html</link>
            <category>IPFW</category>
    
    <comments>http://freebsd.munk.me.uk/archives/13-IPFWstats-SourceForge-Project.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=13</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I&#039;ve just uploaded a tarball containing the IPFWstats files to the sourceforge server and created a minimal homepage for it over there.&lt;br /&gt;
&lt;br /&gt;
The project homepage is:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://sourceforge.net/projects/ipfwstats/&quot;&gt;https://sourceforge.net/projects/ipfwstats/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
and the project website is:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ipfwstats.sourceforge.net/&quot;&gt;http://ipfwstats.sourceforge.net/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
- not too glamourous as yet, will add some HTML to it soon. 
    </content:encoded>

    <pubDate>Fri, 12 Dec 2003 20:50:22 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/13-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>IP Accounting on FreeBSD using ipfw</title>
    <link>http://freebsd.munk.me.uk/archives/7-IP-Accounting-on-FreeBSD-using-ipfw.html</link>
            <category>IPFW</category>
    
    <comments>http://freebsd.munk.me.uk/archives/7-IP-Accounting-on-FreeBSD-using-ipfw.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=7</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=7</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
More info about this project can be found here:&lt;br /&gt;
&lt;a href=&quot;http://jez.hancock-family.com/archives/13_IPFWstats_SourceForge_Project.html&quot;&gt;http://jez.hancock-family.com/archives/13_IPFWstats_SourceForge_Project.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Overview&lt;/h4&gt;&lt;br /&gt;
IPFWstats is a suite of shell, perl and PHP scripts to count traffic on a per-user basis to/from a server.  The statistics are imported into a MySQL database on a daily basis and can then be viewed using a PHP script in a web browser.  A demo of the IPFWstats frontend can be viewed &lt;a href=&quot;http://ipfwstats.munk.me.uk/&quot;&gt;here&lt;/a&gt; - note the frontend was never really &#039;polished&#039;, it just did what I needed it to do at the time!&lt;br /&gt;
&lt;br /&gt;
IPFWstats consists of the following:&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;a Bourne shell script to initialize the per-user IPFW counters&lt;br /&gt;
&lt;li/&gt;a Perl script, ipfw2mysql.pl, to import the IPFWstats into a MySQL database on a daily basis via a cronjob&lt;br /&gt;
&lt;li/&gt;a set of PHP scripts to display the statistics gathered by IPFWstats in a web browser&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
IPFWstats can only count traffic that is transferred directly by processes with the UIDs that it is tracking.  This means IPFWstats cannot by default count network on a per-user basis for requests made to daemons such as httpd, ftpd and smtpd which usually run as a single user - ie www, ftp or smtp users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Installation and Configuration of IPFWstats&lt;/h4&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li/&gt;Load the IPFWstats rulesets on system boot using &lt;a href=&quot;#ipfwstats_rc&quot;&gt;the IPFWstats rc shell script&lt;/a&gt;&lt;br /&gt;
I do this by naming it /usr/local/etc/rc.d/.000.ipfw.sh - this way it loads before anything else in that directory&lt;br /&gt;
&lt;br /&gt;
Be sure to edit the script to use your IP address and to exclude any users you DON&#039;T want to do accounting for - see the &#039;sed&#039; line in the script&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Create a MySQL db with the following tables:&lt;br /&gt;
#&lt;br /&gt;
# Table structure for table &#039;all_traffic&#039;&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE all_traffic (&lt;br /&gt;
  packets_in int(10) unsigned default NULL,&lt;br /&gt;
  packets_out int(10) unsigned default NULL,&lt;br /&gt;
  packets_total int(10) unsigned default NULL,&lt;br /&gt;
  bytes_in int(10) unsigned default &#039;0&#039;,&lt;br /&gt;
  bytes_out int(10) unsigned default &#039;0&#039;,&lt;br /&gt;
  bytes_total int(10) unsigned default NULL,&lt;br /&gt;
  date date default &#039;0000-00-00&#039;&lt;br /&gt;
) TYPE=MyISAM;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Table structure for table &#039;user_traffic&#039;&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE user_traffic (&lt;br /&gt;
  user varchar(15) default &#039;0&#039;,&lt;br /&gt;
  packets_in int(10) unsigned default NULL,&lt;br /&gt;
  packets_out int(10) unsigned default NULL,&lt;br /&gt;
  packets_total int(10) unsigned default NULL,&lt;br /&gt;
  bytes_in int(10) unsigned default &#039;0&#039;,&lt;br /&gt;
  bytes_out int(10) unsigned default &#039;0&#039;,&lt;br /&gt;
  bytes_total int(10) unsigned default NULL,&lt;br /&gt;
  date date default &#039;0000-00-00&#039;&lt;br /&gt;
) TYPE=MyISAM;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;copy &lt;a href=&quot;#ipfw2mysql&quot;&gt;the ipfw2mysql.pl perl script&lt;/a&gt; into a suitable location such as /usr/local/sbin/ipfw2mysql.pl&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;modify &lt;a href=&quot;#ipfw2mysql_vbls&quot;&gt;the ipfw2mysql.pl %db hash to use your mysql db/username/password&lt;/a&gt;:&lt;br /&gt;
&lt;code&gt;
my %db=(
	&#039;host&#039;=&gt;&#039;localhost&#039;,
	&#039;user&#039;=&gt;&#039;CHANGE_ME&#039;,
	&#039;pass&#039;=&gt;&#039;CHANGE_ME&#039;,
	&#039;name&#039;=&gt;&#039;CHANGE_ME&#039;
);
&lt;/code&gt;&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
To view more advanced options for debugging and testing, execute ipfw2mysql.pl with the &#039;-h&#039; switch.&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;Create a cronjob to run the &lt;a href=&quot;#ipfw2mysql&quot;&gt;ipfw2mysql.pl&lt;/a&gt; perl script daily - the following should be sufficient in /etc/crontab:&lt;br /&gt;
&lt;code&gt;
55  23  *   *   *   root    /home/munk/bin/perl/ipfw_stats/ipfw2mysql.pl -q
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;li/&gt;reboot system or just run /usr/local/etc/rc.d/.000.ipfw.sh start&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
If all went well you should be able to run &#039;ipfw show&#039; and view a list of all the counter rules created by &lt;a href=&quot;#ipfwstats_rc&quot;&gt;the IPFWstats rc shell script&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
[12:34:49] root@users /web/ipfwstats.munk.me.uk# ipfw show
00001    317    26671 count ip from any to 1.2.3.4 uid munk
00001      0        0 count ip from any to 1.2.3.4 uid otheruser
...
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Your system is now setup to count traffic on a per-user basis using IPFWstats.&lt;br /&gt;
&lt;br /&gt;
To view the statistics in a web browser, use the IPFWstats PHP frontend - if you require the PHP scripts let me know and I&#039;ll tarball them up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/7-IP-Accounting-on-FreeBSD-using-ipfw.html#extended&quot;&gt;Continue reading &quot;IP Accounting on FreeBSD using ipfw&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Tue, 09 Dec 2003 14:17:44 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/7-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>

</channel>
</rss>