Traffic Accounting with Shorewall


Shorewall allows accounting of traffic with iptaccount. The following script inserts the output of iptaccount into a PostgreSQL Database (without proper input validation). In combination with cron/runwhen this script allows accounting of traffic from multiple interfaces. If the intervals between updates are short the datatype can be changed from bigint to int.

The following is an example schema for the database.