I'm looking for a good free method of logging IP heading information (src/dest IP with timestamp) passing through a Linux router.
I know I can do this with
tcpdump -i eth0 > log.txt
However I'm looking for something a bit more substantial, as this will be running all the time.
If you want detailed logging, I suggest ulogd.
iptables can do this natively. just put a
LOG
orULOG
target early in your chains. You'll also have to play withrsyslogd
to get the iptables logs out of the kernel logging stream and into a file of your choosing. This necessitates you putting some unique characters in the log text you select with the iptables rules (something like":FW:"
) so you can tell rsyslogd to filter based on that string and put it in its own file.I really like using argus for this. It is a software package that promiscuously listens on an interface and writes out flow data similar to (net|j)flows. It uses the client/server model, where the server daemon performs the capture and writes the data files, and the client tools are used to read and analyze the data files. The output files are written into a binary format, so some learning curve in the included tools is necessary.
Using a (nearly) default config what follows is an anonymized version of the basic output:
It is designed to run as a service, however you must figure out the best way to rotate out files depending on your system, storage, and throughput. You should be able to point it at one of your router's interfaces and get all of the information you desire.
As a bonus, tt also comes with a significant number of helper utilities with which you can do fun stuff like traffic graphs, accounting, and other kinds of analysis. See the NSMWiki page for some details on exactly the kind of analysis that can be run.
ntop ? If i understand what you want. that'll give you a nice web interface for all the data, and its easy as pie to install.
Pastmon? mrtg?