FLOW-NFILTER(1)

πŸ“¦ version 0.68.5.1, in fedora 43, fedora 44

πŸ’– FLOW-NFILTER(1) πŸ’–

okay bestie, welcome to flow-nfilter β€” she's a section 1 manual page and she FILTERS FLOWS. let's get into it, no cap. ✨


✨ NAME ✨

flow-nfilter β€” Filter flows.


πŸŽ€ SYNOPSIS πŸŽ€

flow-nfilter [ -hk ]  [ -b big|little ]  [ -C comment ]  [ -d
debug_level ]  [ -f filter_fname ]  [ -F filter_definition ]  [ -v
variable binding ]  [ -z z_level ]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so flow-nfilter filters flows based on criteria you pick. it's giving choose-your-own-adventure but for network flows. πŸ’…

Filters live in a configuration file, and they're made of two things: primitives and a definition. Definitions contain match lines grouped together to form logical AND and OR operations on the flow, using the primitives you selected. A definition may also contain the invert command, which inverts the result of the evaluation. (iconic, honestly.)

Words in the configuration file of the form @VAR or @{VAR:default} get expanded at run-time by setting variable names with the -v option. variable girlies rise up 🌸

Filter primitives begin with the filter-primitive keyword followed by a symbolic name. Each primitive has a type, defined below. Then a list of permit and or deny keywords followed by an argument get evaluated later to figure out if the flow is permitted or denied. The default action for a primitive is to deny, which you can change with the default keyword. Symbolic substitutions are done where appropriate.

The match keyword in a definition selects the criteria to match a primitive. A match type may allow more than one type of primitive β€” for example, the src-ip-addr match type will accept any of {ip-address, ip-address-mask, ip-address-prefix} primitive types. versatile queen πŸ’…

🌈 Primitive types

  • as β€” Bucket β€” Autonomous System Number. e.g. 600,159,3112
  • ip-address-prefix-len β€” Numeric β€” Integer from 0 to 32. e.g. 16-31
  • ip-protocol β€” Bucket β€” Integer from 0 to 255. e.g. 6,17,1
  • ip-tos β€” Bucket β€” Integer from 0 to 255 with mask. e.g. 0xA0/0xE0
  • ip-tcp-flags β€” Bucket β€” Integer from 0 to 255 with mask. e.g. 0x2/0x2
  • ifindex β€” Bucket β€” Integer from 0 to 65535. e.g. 0,5,10
  • engine β€” Bucket β€” Integer from 0 to 255. e.g. 0
  • ip-port β€” Bucket β€” Integer from 0 to 65535. e.g. 80,8080,23,22
  • ip-address β€” Hash β€” List of IP Addresses. e.g. 10.0.0.1
  • ip-address-mask β€” List β€” List of IP address/mask pairs. e.g. 10.1.0.0 255.255.0.0
  • ip-address-prefix β€” Trie β€” List of IP address/mask pairs. e.g. 10.1/16
  • tag β€” Hash β€” List of tags. e.g. 0xFF00
  • tag-mask β€” List β€” List of tags. e.g. 0xF000/0xFF00
  • counter β€” List β€” List of Integers with qualifier. e.g. lt 32
  • time β€” List β€” List of relative time specifiers. e.g. gt 5:00
  • time-date β€” List β€” List of absolute time specifiers. e.g. gt December 12, 2002 5:13:21
  • double β€” List β€” List of doubles with qualifier. e.g. lt 32.0
  • rate β€” Element β€” Rate is calculated as 1/rate. e.g. permit 100

πŸ’œ Match types

  • source-as β€” Source AS β€” primitives accepted: as
  • destination-as β€” Destination AS β€” primitives accepted: as
  • ip-source-address β€” Source IP Address β€” primitives accepted: ip-address, ip-address-mask, ip-address-prefix
  • ip-destination-address β€” Destination IP Address β€” primitives accepted: ip-address, ip-address-mask, ip-address-prefix
  • ip-exporter-address β€” Exporter IP Address β€” primitives accepted: ip-address, ip-address-mask, ip-address-prefix
  • ip-nexthop-address β€” NextHop IP Address β€” primitives accepted: ip-address, ip-address-mask, ip-address-prefix
  • ip-shortcut-address β€” Shortcut IP Address β€” primitives accepted: ip-address, ip-address-mask, ip-address-prefix
  • ip-protocol β€” IP Protocol β€” primitives accepted: ip-protocol
  • ip-source-address-prefix-len β€” Source IP address prefix length β€” primitives accepted: ip-address-prefix-len
  • ip-destination-address-prefix-len β€” Destination IP address prefix length β€” primitives accepted: ip-address-prefix-len
  • ip-tos β€” IP Type Of Service β€” primitives accepted: ip-tos
  • ip-marked-tos β€” IP Type Of Service β€” primitives accepted: ip-tos
  • ip-tcp-flags β€” IP/TCP Flags β€” primitives accepted: ip-tcp-flags
  • ip-source-port β€” Source IP Port eg TCP/UDP β€” primitives accepted: ip-port
  • ip-destination-port β€” Destination IP Port eg TCP/UDP β€” primitives accepted: ip-port
  • input-interface β€” Source ifIndex eg Input Interface β€” primitives accepted: ifindex
  • output-interface β€” Destination ifIndex eg Output Interface β€” primitives accepted: ifindex
  • start-time β€” Start Time of flow β€” primitives accepted: time, time-date
  • end-time β€” End Time of Flow β€” primitives accepted: time, time-date
  • flows β€” Number of flows β€” primitives accepted: counter
  • octets β€” Number of octets β€” primitives accepted: counter
  • packets β€” Number of packets β€” primitives accepted: counter
  • duration β€” Duration of flow in ms β€” primitives accepted: counter
  • engine-id β€” Engine ID β€” primitives accepted: engine
  • engine-type β€” Engine Type β€” primitives accepted: engine
  • source-tag β€” Source Tag β€” primitives accepted: tag, tag-mask
  • destination-tag β€” Destination Tag β€” primitives accepted: tag, tag-mask
  • pps β€” Packets Per Second β€” primitives accepted: double
  • bps β€” Bits Per Second β€” primitives accepted: double
  • random-sample β€” Random Sample β€” primitives accepted: rate

πŸ‘‘ OPTIONS πŸ‘‘

  • -b big|little β€” Byte order of output.
  • -C Comment β€” Add a comment.
  • -d debug_level β€” Enable debugging.
  • -f filter_fname β€” Filter list filename. Defaults to /etc/flow-tools/cfg/filter.
  • -F filter_definition β€” Select the active definition. Defaults to default.
  • -h β€” Display help.
  • -k β€” Keep time from input.
  • -v variable binding β€” Set a variable FOO=bar.
  • -z z_level β€” Configure compression level to z_level. 0 is disabled (no compression), 9 is highest compression.

⭐ TIME/DATE PARSING ⭐

time-date parsing is implemented with getdate.y, a commonly used function to process free-form time date specifications. (she's flexible, we love her 🫢)

Example usage borrowed from cvs:

  • 1 month ago
  • 2 hours ago
  • 400000 seconds ago
  • last year
  • last Monday
  • yesterday
  • a fortnight ago
  • 3/31/92 10:00:07 PST
  • January 23, 1987 10:05pm
  • 22:00 GMT

🌸 EXAMPLES 🌸

An example of filter configuration file:

filter-primitive srate
  type rate
  permit 100

filter-primitive test-as
  type as
  permit 600,159

filter-primitive test-prefix-len
  type ip-address-prefix-len
  permit 32

filter-primitive test-protocol
  type ip-protocol
  permit tcp

filter-primitive test-tos
  type ip-tos
  mask 0xA0
  permit 0xE0

filter-primitive test-tcp-flags
  type ip-tcp-flags
  mask 0x2
  permit 0x2

filter-primitive test-ifindex
  type ifindex
  permit 0,5,10

filter-primitive test-engine
  type engine
  permit 0

filter-primitive test-port
  type ip-port
  permit https
  permit 80
  default deny

filter-primitive test-address
  type ip-address
  permit 0.0.0.1
  permit 0.0.0.2
  default deny

filter-primitive test-address-mask
  type ip-address-mask
  permit 128.146.197.1 255.255.255.255
  permit 128.146.197.2 255.255.255.255

filter-primitive test-prefix
  type ip-address-prefix
  permit 128.146.0.0/16
  default deny

filter-primitive test-tag
  type tag
  permit 0x00
  permit 0x01
  permit 0xFF

filter-primitive test-tag-mask
  type tag-mask
  permit OSU 0xFF
  permit 0xFF 0xFF
  default deny

filter-primitive test-counter
  type counter
  permit lt 5
  permit gt 10
  default deny

filter-primitive test-time-date
  type time-date
  permit gt December 12, 2002 5:13:21

filter-primitive test-time
  type time-date
  permit gt 12:15:00

filter-definition sample-1-in-100
  match random-sample srate

filter-definition t1
  match engine-type test-engine
  or
  match destination-tag test-tag-mask

Display all flows with a destination port of 80 or source port of 25 (smtp) starting after Dec 12, 2001. The file test is populated with the following:

filter-primitive port80
  type ip-port
  permit 80

filter-primitive port25
  type ip-port
  permit smtp

filter-primitive dec12
  type time-date
  permit gt Dec 12, 2001

filter-definition foo
  match ip-source-port port80
  match start-time dec12
  or
  match ip-destination-port port25
  match start-time dec12

and then, the moment you've all been waiting for:

flow-cat flows | flow-nfilter -ftest -Ffoo | flow-print

ate. πŸ”₯


πŸ“ FILES πŸ“

Configuration files:

  • Symbols β€” /etc/flow-tools/sym/*
  • Tag β€” /etc/flow-tools/cfg/tag.cfg
  • Filter β€” /etc/flow-tools/cfg/filter.cfg

πŸ’€ BUGS πŸ’€

None known. (she's perfect, we been knew πŸ’…)


🧚 AUTHOR 🧚

Mark Fullmer <maf@splintered.net>


πŸ’œ SEE ALSO πŸ’œ

flow-tools(1)


and that's the whole page bestie!! ✨ this was manual page FLOW-NFILTER(1), dated 26 Август 2010, straight outta the flow-tools source. tysm for reading, go filter some flows, mwah πŸ«ΆπŸ’–

πŸ“¦ where this page comes from