Getting per-ip traffic stats from PF

bandwidthloggingmonitoringpf

Is there a way to get per-ip traffic stats from PF on OpenBSD 4.9? pfctl can give me the total traffic (bytes) for a given label, and pfstats for a given interface, and pftop can give me a "live" view of traffic, but I'm looking for a historical view- i.e. something I can look at and say "yesterday this IP used x bytes"

Best Answer

You can do this through a slightly convoluted (but very easy to manage long-term, and pretty well-understood) adaptation of Netflow traffic monitoring (using OpenBSD's pflow support).

Basically export netflow data for all your traffic, grab it with Flow-Tools, and feed it to something like JKFlow to parse (and graph/report on). There are also many other NetFlow crunching/graphing programs, and a number of real-time monitoring systems available.
The upside is that exporting in NetFlow format opens up a huge array of tools for you to use -- The downside is the overhead and complexity of running all that extra code.

You may also be able to magic something up using MRTG, but I'm not as familiar with that.