NF2CSV(1)
π nf2csv β bestie edition π
okay so you found the nf2csv(1) page, from the General Commands Manual, and honestly? it's giving "underrated icon". let me walk you through it π«Ά
β¨ NAME β¨
nf2csv β iptables to CSV data. literally that's the whole gig, bestie π
π SYNOPSIS π
nf2csv [options]
πΈ DESCRIPTION πΈ
so nf2csv parses iptables log messages and generates comma-separate value formatted data. comma-separate value, yes, that's how the page says it, we don't fix, we respect π
why do you care? because this is useful to provide input to the AfterGlow project (see http://afterglow.sourceforge.net) so your iptables logs can be visualized graphically. no cap, your boring firewall logs become art β¨
an interesting application of nf2csv and AfterGlow is to parse and visualize the iptables logfiles made available by the Honeynet project in their Scan of the Month challenges. the Scan30 and Scan34 challenges (see http://www.honeynet.org/scans/scan30/ and http://www.honeynet.org/scans/scan34/) contain extensive iptables logfiles, and some graphical representations of these can be viewed here: http://www.cipherdyne.org/psad/honeynet/. go look at them, they're lowkey gorgeous π¦
also, the psad program has the ability to generate CSV data from iptables logs with its --CSV mode. so many options, we love a versatile queen π
β OPTIONS β
-f,--fields <tokens>β specify the set of fields that should be printed from iptables log messages. the most common usage of this argument isSRC DST DPTto print the source and destination IP addresses, followed by the destination port number. available fields to print include:SRC,SPT,DST,DPT,PROTO,LEN,IN,TOS,TTL,SEQ,ID,TYPE,CODE(and these can also be referred to assrc,dst,sp,dp,proto,ip_len,intf,tos, andttl). there are several additional fields that are not given specific tags within iptables log messages, and these can be included by specifying one of the following:flags,top_opts,ip_opts,chain,log_prefix,frag_bit,src_mac,dst_mac, andudp_len. each of these fields accepts a search criteria in the form of a numeric comparison, string match, or IP match. see the EXAMPLES section below for more information. π-u,--unique-linesβ only print unique output lines. this can drastically reduce the output ofnf2csvdepending on the characteristics of the iptables logfile that is being parsed. dedupe era π₯-m,--max-lines <num>β specify the maximum number of output linesnf2csvwill generate. this is useful for providing a limited set of data to AfterGlow in order to make visualizations more clear and less cluttered. no more visual chaos, we keep it cute π-r,--regex <regex>β specify a regular expression that must match against the entire iptables log message in order for it to be included within the CSV output. this allows log messages to be included from the output with all of the flexibility of regular expressions. see the EXAMPLES section below for more information. iykyk β¨-n,--neg-regex <regex>β specify a regular expression that must not match against the iptables log message in order for it to be included within the CSV output. this allows log messages to be excluded from the output with all of the flexibility of regular expressions. see the EXAMPLES section below for more information. the girl who says no π-s,--start-line <line>β specify the starting line wherenf2csvbegins to process iptables log data. if you are processing a huge file with thousands of iptables log messages this option can be useful to parse a specific chunk of this data. also see the--end-lineoption below. π-e,--end-line <line>β specify the last line of iptables log data thatnf2csvwill parse. and that's the end of that chapter, bestie π§
π EXAMPLES π
the following examples illustrate the command line arguments that could be supplied to nf2csv in a few situations. copy these exactly, they're canon:
print source and destination IP addresses and the destination port number:
$ nfcsv -f src dst dp
same as above, but now require that the source IP come from the 11.11.11.0/24 subnet:
$ nfcsv -f src:11.11.11.0/24 dst dp
display instances of the MyDoom worm:
$ nfcsv -f src dst dp:3127
display packets that have low TTL values:
$ nfcsv -f src dst ttl:<10
display all traffic to or from the host 11.11.11.67 (this sets up an OR condition between the src and dst fields):
$ nfcsv -f src dst dp -r 11.11.11.67
display likely instances of Window Messenger popup spam attempts (note the use of the --regex argument to require minimal lengths on the UDP length field and source port, but the output contains the destination port of 1026):
$ nfcsv -f src dst dp -r SPT={4}.*LEN=[4-9]{2}
π SEE ALSO π
the crossover episode you didn't know you needed π«Ά
π AUTHOR π
Michael Rash <mbr@cipherdyne.org>
shoutout to the author, main character energy fr fr π
π BUGS π
send bug reports to mbr@cipherdyne.org. suggestions and/or comments are always welcome as well. be nice, be specific, be iconic π
π¦ DISTRIBUTION π¦
nf2csv is distributed with the psad project (http://www.cipherdyne.org/psad/) under the GNU General Public License (GPL), and the latest version may be downloaded from http://www.cipherdyne.org/ πΈ
periodt. that's the license, that's the link, that's the law π
and that's a wrap on the nf2csv(1) page bestie β this one shipped on Linux, dated Jun, 2006, and it still ate. go parse some logs and make something pretty ππβ¨
π¦ where this page comes from
- alpine 3.24: psad-doc 2.4.6-r4 Β· GPL-2.0-or-later
- debian bookworm: psad 2.4.6-3 Β· GPL-2.0-or-later
- debian trixie: psad 2.4.6-3+b1 Β· GPL-2.0-or-later
- fedora 43: psad 2.4.6-23.fc43 Β· GPL-2.0-or-later
- fedora 44: psad 2.4.6-24.fc44 Β· GPL-2.0-or-later
- ubuntu jammy: psad 2.4.6-2 Β· GPL-2.0-or-later
- ubuntu noble: psad 2.4.6-3 Β· GPL-2.0-or-later
- ubuntu questing: psad 2.4.6-3
- ubuntu resolute: psad 2.4.6-3build1 Β· GPL-2.0-or-later
- ubuntu stonking: psad 2.4.6-3build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms