YAF: Documentation

Description of YAF as a Whole

YAF's purpose is to consume packets and turn them into flows to be processed by downstream tools enabling analysts to provide network situational awareness. YAF emits data in the IPFIX format (RFC 7011). All data fields are defined by IPFIX information elements with fixed binary types. YAF's job is to build flows augmented with enrichments and deep packet inspection (DPI) metadata that are contained in named fields. These fields are in prescribed locations in the record, allowing downstream tools to know where to access them. Other downstream tools may carve records to make them more usable as a final product for analysts. YAF's goal is to produce flows as fast as possible with as much data as possible with data organized in an accessible manner.

The manner in which YAF does this can be configured to serve your particular data needs. YAF's processing can be broken down into four main sections, each of which can be configured independently: Packet Consumption, Building and Managing the Flow Table, Data Stored and Enrichments for Each Flow, and Emitting Data. While there are defaults for almost every option, utilizing YAF's options can provide data tailored for use by your analysts.

There are also ways to manage the YAF program itself such as Logging, Privileges, and Configuration Files that are more about YAF as a process than about flow generation.

Packet Consumption

The user must specify the source of the packets for YAF to consume. The two broad categories of options are live capture from a network or reading PCAP files. One the source is declared, there are decoding options that allow the filtering of packets, and ways to configuring fragment handling regardless of the input source type. If the data will come from PCAP, there are additional capabilities available to index them and query for the packets making up a particular flow.

Input Specification

Live Packet Capture

The --live option declares the data will be consumed from an active interface and specifies the overall type of interface. These interface types include pfring, dag, napatech, netronome, zc (pfring zero copy), and pcap (reading packets using libpcap). The interfaces details are declared with --in. To have physical interface details added to flows, specify --export-interface, and values will appear in ingressInterface and egressInterface fields of flow records.

Example yaf command for Napatech

/usr/local/bin/yaf --live pcap --in napa_lb0    \
    --out /data/test_napa_lb0.ipfix --silk      \
    --dpi --max-payload 2048 --verbose          \
    --log=/data/manual/logs/test_napa_lb0.log

NOTE: The Napatech card allowed for having multiple interfaces to process incoming packets. The interface is labeled as "napa_lbx", where x is an integer. You have (at least) up to 16 interfaces running at once (napa_lb0, napa_lb1,... napa_lb14, napa_lb15).

Example yaf command for Netronome

/usr/local/bin/yaf --live pcap --in netro_intf_0    \
    --out /data/test_netro_intf_0.ipfix --silk      \
    --dpi --max-payload 2048 --verbose              \
    --log=/data/manual/logs/test_netro_intf_0.log

NOTE: The Netronome card had 4 network interfaces already named. The name of the interfaces were not actually netro_intf_x, where x is an integer. They were preset and the names were not easy to remember. The command for Netronome is very similar to the command for Napatech.

Integration with Specific Network Cards

See this page.

Reading from PCAP Files

YAF can consume packets from a fixed set of PCAP files in three ways:

For all input categories, a BPF filter may be used to filter incoming data with the --filter options. This is available when reading live packets using libpcap (not dag, napatech, or netronome), or reading from PCAP files. The --filter option takes a parameter of a filter string as described by the tcpdump(1) and pcap-filter(7) manual pages.

Input Options

Packet Decoding

The yaf packet decoder's behavior can be modified with these options. None of these options are required; the default behavior for each option when not present is noted.

YAF can be configured to read only IPv4 or IPv6 packets with --ip4-only and --ip6-only respectively.

YAF attempts to reassemble packet fragments by default with a 30 second fragment timeout. It can be configured to ignore all fragmented packets with --no-frag. The maximum number of fragments that YAF holds onto can be specified with --max-frags, with a default of no maximum.

Packets encapsulated with GRE version 0 can be extracted to make flows of encapsulated packets with --gre-decode. The default is that packets in GRE tunnels are not extracted, and those flows have IP protocol 47.

PCAP Creation and Indexing

YAF has the capability to write the packets it is processing into rolling PCAP files. This feature is enabled with --pcap. These packets can come live from the wire or from input PCAP files. The files YAF writes can be bounded by output file size using --max-pcap (default 5MB) and by time using --pcap-timer (unlimited by default). Instead of rolling PCAP files containing packets from all flows YAF can be configured to write the packets from each flow into individual pcaps with --pcap-per-flow. YAF will only write --max-payload bytes of each packet to the PCAP file. The contents of an output PCAP file can be restricted to an individual flow by specifying the flow key hash on the command line using --hash. The specificity of --hash can be enhanced by adding the start time of the flow with --stime.

Independent of writing its own PCAP files, YAF can create a file listing the PCAP files containing packets that make up each flow. This is done by specifying a filename prefix using --pcap-meta-file. That file will have entries containing: {yafFlowKeyhash, flowStartMilliseconds, PCAP file name}, where the filename is the output PCAP if --pcap is present, or the input file that packets were read from if not. This file will have 1 line per {flow, pcap file} combination. The file will rotate after 4.5 million lines, around 2GB.

Taking PCAP indexing a step farther, YAF can write one line to the meta file per packet, with the additional specification of the offset into that PCAP, and the length of the packet. This is enabled with --index-pcap. The creation of this advanced meta file enables a separate program, yafMeta2Pcap to retrieve the packets that make up an individual flow and write them to a new PCAP file. --pcap-meta-file must be present to enable full pcap indexing.

Building and Managing the Flow Table

YAF uses the 5-tuple (source IP, destination IP, source port, destination port, protocol) plus the VLAND ID to group packets into flows. To have YAF not factor VLAN ID into determining flow uniqueness, specify --no-vlan-in-key. When there isn't a packet indicating that the flow should be closed and emited, such as a TCP FIN packet, YAF has other mechanisms to manage the flow table and close flows on its own. YAF closes flows due to inactivity. This interval can be set with --idle-timeout, with a default of 300 seconds (5 minutes). By default, YAF will flush a flow that has been active for 1800 seconds (30 minutes). This threshold can be changed with --active-timeout. A maximum number of active flows can be specified with --max-flows. If this is set, YAF will begin to expire flows that have been idle for the longest time when the maximum active flow count has been reached.

Data Stored for Each Flow and Enhancements

In addition to basic flow information, YAF can augment flows with information as specified by the user. This section describes all of the additional options beyond standard flow fields that YAF can provide.

Flow Settings

These settings change what, and how, YAF stores flow information.

Flow Enhancements

Each of these settings add data to every flow. Some are additional fields pulled from individual packets, while others add metadata about the packets that make up a flow. All of the options in this section may be used together in any combination. None of the settings below are on by default. Other than --dpi, each of the settings adds fields to the core, or top-level, flow record. --dpi tells YAF to populate yafDPIList, the subTemplateList used to store deep packet inspection metadata tailored to the specific protocol used by the flow. The contents of the yafDPIList subTemplateList are determined by the value in the silkAppLabel field.

Since many of these options in this section examine the packet payload, you must also supply the --max-payload option when using them. Some of these options may not be available and depend on how your version of yaf was built.

Flow Changes

Emitting Records and Output

YAF needs to be told how and where to write the records it generates. All output will be in the IPFIX format. Using a combination of --out and --ipfix, YAF can be configured write records to local files, local sockets, or remote hosts. Sockets can use SCTP, TCP, or UDP. If no option is given, YAF writes its output file to standard output.

Writing flows to a socket

To write flows to a socket, use --out to specify the hostname or IP address of the destination, and --ipfix to specify the transport protocol to use: tcp, udp, or sctp. The port to use may be specified with --ipfix-port. If no port is specified, the default port of 4739 is used, or 4740 if TLS is utilized (--tls).

yaf --out 192.0.2.3 --ipfix tcp --ipfix-port 18000

Writing flows to a single file

To write all flows to a single file, specify the filename with --out. This can be a full path, or path relative to where YAF is running.

yaf --out flows.yaf

yaf --out /data/flows.yaf

Writing flows to a stream of files

The standard use of YAF is long term monitoring of a network, where the flows cannot fit into one file. YAF can be configured to write to the current file for a fixed amount of time, then close the file and open a new one with a different name. This is specified with a combination of --out and --rotate. In this case, the parameter passed to --out is a file prefix to use for the series of files. The prefix will be followed by a suffix containing a timestamp in YYYYMMDDhhmmss format, and a decimal serial number with a .yaf file extension. The rotating interval is specified in seconds with --rotate. Files can be locked while being written to by specifying --lock.

To write flows to 5 minute files in /data with the file prefix "example":

yaf --out /data/example --rotate 300

Export Options

Additional Records

YAF has three non-flow record types it can generate and emit that augment the flows it produces. The records give collection systems additional information on data contents and monitoring mechanics. There are also IPFIX-related records such as template records (required) and information element detail records (optional).

Additional Record Options

YAF Programmatic Options

These options configure the YAF process, independent of flow related features. They include dropping privilege, logging, configuration file specification, and others.

Logging Options

These options are used to specify how log messages are routed. YAF can log to standard error, regular files, or the UNIX syslog facility.

Privilege Options

These options are used to cause YAF to drop privileges when running as root for live capture purposes.

Configuration File

The YAF configuration file can be used instead of or in addition to command line arguments.

Options for Running as a Daemon

Information Options

These options provide information about the yaf program.

YAF 3 Records and Templates

Base / Default Bi-FLOW

Field Name IPFIX
(PEN,NUM)
Size and Type When it's on SiLK Field Mapping
Description
flowStartMilliseconds (0, 152) 8 bytes unsigned Always STIME
Flow start time in milliseconds since 1970-01-01 00:00:00 UTC
flowEndMilliseconds (0, 153) 8 bytes unsigned Always ETIME
Flow end time in milliseconds since 1970-01-01 00:00:00 UTC.
octetTotalCount (0, 85) 8 bytes unsigned
(or 4 if reduced-length encoding)
not --delta (default) BYTES
Number of bytes in the forward direction of the flow
reverseOctetTotalCount (29305, 85) 8 bytes unsigned
(or 4 if reduced-length encoding)
not --delta (default) and
not --uniflow (default)
BYTES
Number of bytes in the reverse direction of the flow
octetDeltaCount (0, 1) 8 bytes unsigned
(or 4 if reduced-length encoding)
--delta BYTES
Number of bytes in the forward direction of the flow
reverseOctetDeltaCount (29305, 1) 8 bytes unsigned
(or 4 if reduced-length encoding)
--delta and
not --uniflow (default)
BYTES
Number of bytes in the reverse direction of the flow
packetTotalCount (0, 86) 8 bytes unsigned
(or 4 if reduced-length encoding)
not --delta (default) PACKETS
Number of packets in the forward direction of the flow
reversePacketTotalCount (29305, 86) 8 bytes unsigned
(or 4 if reduced-length encoding)
not --delta (default) and
not --uniflow (default)
PACKETS
Number of packets in the reverse direction of the flow
packetDeltaCount (0, 2) 8 bytes unsigned
(or 4 if reduced-length encoding)
--delta PACKETS
Number of packets in the forward direction of the flow
reverseDeltaTotalCount (29305, 2) 8 bytes unsigned
(or 4 if reduced-length encoding)
--delta and
not --uniflow (default)
PACKETS
Number of packets in the reverse direction of the flow
sourceIPv4Address (0, 8) 4 byte binary IP Address Any IPv4 flow SIP
(and DIP if biflow)
IPv4 address of the flow source or biflow initiator
destinationIPv4Address (0, 12) 4 byte binary IP address Any IPv4 flow DIP
(and SIP if biflow)
IPv4 address of the flow destination or biflow responder
sourceIPv6Address (0, 27) 16 bytes binary IP address Any IPv6 flow SIP_V6
(and DIP_V6 if biflow)
IPv6 address of the flow source or biflow initiator
destinationIPv6Address (0, 28) 16 bytes binary IP address Any IPv6 flow DIP_V6
(and SIP_V6 if biflow)
IPv6 address of the flow destination or biflow responder
sourceTransportPort (0, 7) 2 bytes unsigned Always SPORT
(and DPORT if biflow)
TCP or UDP port on the flow source or biflow initiator endpoint.
destinationTransportPort (0, 8) 2 bytes unsigned Always DPORT
(and SPORT if biflow)
TCP or UDP port on the flow destination or biflow responder endpoint. For ICMP flows, contains (ICMP-type * 256 + ICMP-code).
flowAttributes (6871, 40) 2 bytes unsigned Always ATTRIBUTES (Bit 1 only)

Attributes of forward direction of flow:

Bit 1: All packets in the forward direction have fixed size. For TCP flows, only packets that have payload will be considered (to avoid TCP handshakes and teardowns).

Bit 2: At least one packet in the forward direction was received out-of-sequence.

Bit 3: Host may be MP_CAPABLE (MPTCP-capable). For TCP flows, this bit will be set if a packet in the flow was seen that had the MP_CAPABLE TCP option or attempted an MP_JOIN operation.

Bit 4: Forward flow contains packets that were fragmented.

reverseFlowAttributes (6871, 16424) 2 bytes unsigned not --uniflow (default) ATTRIBUTES (Bit 1 only)

Attributes of reverse direction of flow:

Bit 1: All packets in the reverse direction have fixed size. For TCP flows, only packets that have payload will be considered (to avoid TCP handshakes and teardowns).

Bit 2: At least one packet in the reverse direction was received out-of-sequence

Bit 3: Host may be MP_CAPABLE (MPTCP-capable) For TCP flows, this bit will be set if a packet in the flow was seen that had the MP_CAPABLE TCP option or attempted an MP_JOIN operation.

Bit 4: Reverse flow contains packets that were fragmented.

protocolIdentifier (0, 4) 1 byte unsigned Always PROTOCOL
IP protocol of the flow
flowEndReason (0, 136) 1 byte unsigned Always ATTRIBUTES
(Bits 0x80 and 0x02)

Flow end reason code, as defined by the IPFIX Information Model. Always present. In --silk mode, the high-order bit is set if the flow was created by continuation.

0x01: idle timeout The flow was terminated because it was considered to be idle.

0x02: active timeout The flow was terminated for reporting purposes while it was still active, for example, after the maximum lifetime of unreported flows was reached.

0x03: end of flow detected The flow was terminated because the Metering Process detected signals indicating the end of the flow, for example, the TCP FIN flag.

0x04: forced end The flow was terminated because of some external event, for example, a shutdown of the Metering Process initiated by a network management application.

0x05: lack of resources The flow was terminated because of lack of resources available to the Metering Process and/or the Exporting Process.

0x08: continuation Only set in --silk mode, indicates that this flow is a continuation of a previous flow that exceeded a timeout.

0x1f: udp-uniflow A special value set for UDP flows created in --udp-uniflow mode.

silkAppLabel (6871, 33) 2 bytes unsigned --applabel or --dpi APPLICATION
Application label, defined as the primary well-known port associated with a given application.
reverseFlowDeltaMilliseconds (6871, 24) 4 bytes unsigned not --uniflow (default)
Difference in time in milliseconds between first packet in forward direction and first packet in reverse direction. Correlates with (but does not necessarily represent) round-trip time. Present if flow has a reverse direction.
vlanId (0, 58) 2 bytes unsigned Always
802.1q VLAN tag of the first packet in the forward direction of the flow.
reverseVlanId (29305, 58) 2 bytes unsigned not --uniflow (default)
802.1q VLAN tag of the first packet in the reverse direction of the flow.
ipClassOfService (0, 5) 1 byte unsigned Always
For IPv4 packets, this is the value of the TOS field in the IPv4 header. For IPv6 packets, this is the Traffic Class field in the IPv6 header.
reverseIpClassOfService (29305, 5) 1 byte unsigned not --uniflow (default)
For IPv4 packets, this is the value of the TOS field in the IPv4 header in the reverse direction. For IPv6 packets, this is the Traffic Class field in the IPv6 header in the reverse direction.
payloadEntropy (6871, 35) 1 byte unsigned --entropy
Shannon Entropy calculation of the forward payload data.
reversePayloadEntropy (6871, 16419) 1 byte unsigned --entropy
Shannon Entropy calculation of the reverse payload data.
mptcpInitialDataSequenceNumber (6871, 289) 8 bytes unsigned Any MPTCP flow
The initial data sequence number found in the MPTCP Data Sequence Signal (DSS) Option.
mptcpReceiverToken (6871, 290) 4 bytes unsigned Any MPTCP flow
The token used to identify an MPTCP connection over multiple subflows. This value is found in the MP_JOIN TCP Option for the initial SYN of a subflow.
mptcpMaximumSegmentSize (6871, 291) 2 bytes unsigned Any MPTCP flow
The maximum segment size reported in the Maximum Segment Size TCP Option. This should be consistent over all subflows.
mptcpAddressId (6871, 292) 1 byte unsigned Any MPTCP flow
The address ID of the subflow found in the SYN/ACK of an MP_JOIN operation.
mptcpFlags (6871, 293) 1 byte unsigned Any MPTCP flow

Various MPTCP Values:

Bit 1: Priority was changed during the life of the subflow (MP_PRIO was seen)
Bit 2: Subflow has priority at setup (backup flag was not set at initialization).
Bit 3: Subflow failed. (MP_FAIL option was seen).
Bit 4: Subflow experienced fast close. (MP_FASTCLOSE options was seen).

yafDPIList (6871, 432) variable-length subTemplateList --dpi
SubTemplateList containing DPI information for the protocol specified in silkAppLabel
sourceMacAddress (0, 56) 6 bytes unsigned --mac
Source MAC Address of the first packet in the forward direction of the flow.
destinationMacAddress (0, 80) 6 bytes unsigned --mac
Destination MAC Address of the first packet in the reverse direction of the flow.
osName (6871, 36) variable-length string --p0fprint
p0f OS Name for the forward flow based on the SYN packet and p0f SYN Fingerprints.
osVersion (6871, 37) variable-length string --p0fprint
p0f OS Version for the forward flow based on the SYN packet and p0f SYN Fingerprints.
osFingerprint (6871, 107) variable-length string --p0fprint
p0f OS Fingerprint for the forward flow based on the SYN packet and p0f SYN fingerprints.
reverseOsName (6871, 16420) variable-length string --p0fprint and
not --uniflow (default)
p0f OS Name for the reverse flow based on the SYN packet and p0f SYN Fingerprints.
reverseOsVersion (6871, 16421) variable-length string --p0fprint and
not --uniflow (default)
p0f OS Version for the reverse flow based on the SYN packet and p0f SYN fingerprints.
reverseOsFingerprint (6871, 16491) variable-length string --p0fprint and
not --uniflow (default)
p0f OS Fingerprint for the reverse flow based on the SYN packet and p0f SYN Fingerprints.
firstPacketBanner (6871, 38) variable-length octetArray --fpexport
IP and transport headers for first packet in forward direction to be used for external OS Fingerprinters.
secondPacketBanner (6871, 39) variable-length octetArray --fpexport
IP and transport headers for second packet in forward direction (third packet in sequence) to be used for external OS Fingerprinters.
reverseFirstPacketBanner (6871, 16422) variable-length octetArray --fpexport and
not --uniflow (default)
IP and transport headers for first packet in reverse direction to be used for external OS Fingerprinters.
payload (6871, 18) variable-length octetArray --export-payload
Initial n bytes of forward direction of flow payload.
reversePayload (6871, 16402) variable-length octetArray --export-payload and
not --uniflow (default)
Initial n bytes of reverse direction of flow payload.
ingressInterface (0, 10) 4 bytes unsigned --ingress
or --export-interface
IN
(and OUT if biflow)
The index of the IP interface where packets of this flow are being received.
egressInterface (0,14) 4 bytes unsigned --egress
or --export-interface
OUT
(and IN if biflow)
The index of the IP interface where packets of this flow are being received.
dataByteCount (6871, 502) 8 bytes unsigned --flow-stats
Total bytes transferred as payload.
averageInterarrivalTime (6871, 503) 8 bytes unsigned --flow-stats
Average number of milliseconds between packets.
standardDeviationInterarrivalTime (6871, 504) 8 bytes unsigned --flow-stats
Standard deviation of the interarrival time for up to the first ten packets.
tcpUrgTotalCount (0, 223) 4 bytes unsigned --flow-stats
The number of TCP packets that have the URGENT Flag set.
smallPacketCount (6871, 500) 4 bytes unsigned --flow-stats
The number of packets that contain less than 60 bytes of payload.
nonEmptyPacketCount (6871, 501) 4 bytes unsigned --flow-stats
The number of packets that contain at least 1 byte of payload.
largePacketCount (6871, 510) 4 bytes unsigned --flow-stats
The number of packets that contain more than 225 bytes of payload.
firstNonEmptyPacketSize (6871, 505) 2 bytes unsigned --flow-stats
Payload length of the first non-empty packet.
maxPacketSize (6871, 506) 2 bytes unsigned --flow-stats
The largest payload length transferred in the flow.
standardDeviationPayloadLength (6871, 508) 2 bytes unsigned --flow-stats
The standard deviation of the payload length for up to the first 10 non empty packets.
firstEightNonEmptyPacketDirections (6871, 507) 1 byte unsigned --flow-stats
Represents directionality for the first 8 non-empty packets. 0 for forward direction, 1 for reverse direction.
reverseDataByteCount (6871, 16886) 8 bytes unsigned --flow-stats and
not --uniflow (default)
Total bytes transferred as payload in the reverse direction.
reverseAverageInterarrivalTime (6871, 16887) 8 bytes unsigned --flow-stats and
not --uniflow (default)
Average number of milliseconds between packets in reverse direction.
reverseStandardDeviationInterarrivalTime (6871, 16888) 8 bytes unsigned --flow-stats and
not --uniflow (default)
Standard deviation of the interarrival time for up to the first ten packets in the reverse direction.
reverseTcpUrgTotalCount (29305, 223) 4 bytes unsigned --flow-stats and
not --uniflow (default)
The number of TCP packets that have the URGENT Flag set in the reverse direction.
reverseSmallPacketCount (6871, 16884) 4 bytes unsigned --flow-stats and
not --uniflow (default)
The number of packets that contain less than 60 bytes of payload in reverse direciton.
reverseNonEmptyPacketCount (6871, 16885) 4 bytes unsigned --flow-stats and
not --uniflow (default)
The number of packets that contain at least 1 byte of payload in reverse direction.
reverseLargePacketCount (6871, 16894) 4 bytes unsigned --flow-stats and
not --uniflow (default)
The number of packets that contain more than 225 bytes of payload in the reverse direction.
reverseFirstNonEmptyPacketSize (6871, 16889) 2 bytes unsigned --flow-stats and
not --uniflow (default)
Payload length of the first non-empty packet in the reverse direction.
reverseMaxPacketSize (6871, 16890) 2 bytes unsigned --flow-stats and
not --uniflow (default)
The largest payload length transferred in the flow in the reverse direction.
reverseStandardDeviationPayloadLength (6871, 16892) 2 bytes unsigned --flow-stats and
not --uniflow (default)
The standard deviation of the payload length for up to the first 10 non empty packets in the reverse direction.
initialTCPFlags (6871, 14) 1 byte unsigned Any TCP flow initialFlags
TCP flags of initial packet in the forward direction of the flow.
unionTCPFlags (6871, 15) 1 byte unsigned Any TCP flow sessionFlags
Union of TCP flags of all packets other than the initial packet in the forward direction of the flow.
tcpSequenceNumber (0, 184) 4 bytes unsigned Any TCP flow
Initial sequence number of the forward direction of the flow.
reverseTcpSequenceNumber (29305, 184) 4 bytes unsigned Any TCP flow and
not --uniflow (default)
Initial sequence number of the reverse direction of the flow.
reverseInitialTCPFlags (6871, 16398) 1 byte unsigned Any TCP flow and
not --uniflow (default)
initialFlags
Initial sequence number of the reverse direction of the flow.
reverseUnionTCPFlags (6871, 16399) 1 byte unsigned Any TCP flow and
not --uniflow (default)
sessionFlags
Union of TCP flags of all packets other than the initial packet in the reverse direction of the flow.
ndpiL7Protocol (6871, 300) 2 bytes unsigned --ndpi
The protocol as determined by analysis with nDPI, the ntop-maintained superset of the OpenDPI library.
ndpiL7SubProtocol (6871, 301) 2 bytes unsigned --ndpi
The subprotocol as determined by analysis with nDPI.
mplsTopLabelStackSection (0, 70) 3 bytes octetArray Built with MPLS
The MPLS Label from the top of the MPLS label stack entry. yaf does not include the Experimental bits and Bottom of the Stack bit in the export field.
mplsLabelStackSection2 (0, 71) 3 bytes octetArray Built with MPLS
The MPLS Label from the MPLS label stack entry immediately before the top entry. yaf does not include the Experimental bits and Bottom of the Stack bit in the export field.
mplsLabelStackSection3 (0, 72) 3 bytes octetArray Built with MPLS
The MPLS Label from the third entry in the MPLS label stack. yafdoes not include the Experimental bits and Bottom of the Stack bit in the export field.
subTemplateMultiList (0, 293) variable-length subTemplateMultiList Built with plugin support
Contains non-DPI things. Examples include DHCP Fingerprinting

DPI

Lua Configuration Files

YAF Configuration File

The yaf configuration file is an alternative to running yaf with command line options. The YAF configuration file is written in the Lua language, and this file may be specified on the yaf command line with the --config option. A template file is provided in /usr/local/share/yaf/yaf.init; the file should be copied and customized for your needs.

The syntax of the configuration file is explained by annotated examples.

-- This is a comment.
-- Anything not marked as Required is optional.

-- The only required variables are "input" and "output".
-- All other variables are optional.

The sample configuration file must be customized by the user, and to ensure that happens, it raises an error. Delete the error when customizing the file.

-- Remove these lines when you customize this file
error [[You are attempting to use yaf.init without customizing it.
You must remove the error statement from the beginning of the file.]]

Specifying the input is required.

 -- A variable named "input" is required; its value must be a table.
 -- It specifies the input to yaf.

This example has yaf read PCAP data from an interface.

input = {

    -- The input table must have a key named "type". The default
    -- input "type" is "file".  Valid values are "pcap", "dag",
    -- "napatech", "netronome", "pfring", "zc", "file", and "caplist".
    type="pcap",

    -- In "pcap", "dag", "napatech", "netronome", "pfring", and "zc",
    -- a "inf" field is required.  Its value is the name of the interface
    -- that yaf will read. In the "zc" case, it is the cluster ID
    -- that yaf should listen to.
    inf="en0",

    -- Optional parameters for all input types
    -- are "export_interface" and "force_read_all".
    -- Both options expect boolean values "true" and "false".
    export_interface=true}

This example has yaf read PCAP data from a file.

input = {

    type = "file",

    -- If type is "file", a "file" is expected with the
    -- full path to the PCAP file.
    file="/pcaps/mypcap.pcap"}

This example has yaf read PCAP data from the standard input. The type does not need to be specified since "file" is the default.

-- Use a file name of "-" to read from stdin.
input = {file = "-"}

This example has yaf read PCAP data from a list of files.

input = {
    type = "caplist",
    -- If type is "caplist", a "file" is expected which is
    -- the full path to a text file that contains a list
    -- of PCAP files in the order that they will be processed.
    file = "/data/pcapfile.txt",

    -- An optional parameter to "caplist" types, is "noerror"
    -- which expects a boolean value (true/false). If true,
    -- yaf will continue to process the list if it encounters
    -- an error in a PCAP file.
    noerror = true}

Specifying the output is required.

-- A variable named "output" is required; its value must be a table.
-- It specifies the output of yaf.

This example has yaf write to a TCP socket.

output = {
    -- The host where an IPFIX collector is listening
    host = "localhost",

    -- The value to "port" must be in quotation marks.
    port = "18000",

    -- Acceptable protocol types are "tcp", "udp", and "sctp".
    -- If protocol is "udp", the optional "udp_temp_timeout" key is
    -- also available.
    protocol = "tcp"}

This example has yaf write to an IPFIX file that rotates every 200 seconds. The output file will be locked until yaf has closed the file.

output = {
    file = "/data/yaffile.yaf",
    rotate = 200,
    lock = true}

This example has yaf write IPFIX data to the standard output.

-- Use a file name of "-" to write to stdout.
output = {file = "-"}

Optional keywords.

-- The "decode" variable is optional. Its value must be a table.
-- All keywords within the "decode" variable expect a boolean
-- response (true/false).

decode = {
    -- If the "gre" variable is set to "true", gre decoding will be enabled.
    gre = false,

    -- If the "ip4_only" variable is set to "true", yaf will only
    -- process IPv4 flows.
   ip4_only = false,

    -- If the "ip6_only" variable is set to "true", yaf will only
    -- process Ipv6 flows.
   ip6_only = false,

    -- If the "nofrag" variable is set to "true", yaf will not
    -- process fragmented packets.
    nofrag = false}

-- The "export" variable is optional. Its value must be a table.
-- All keywords within the "export" variable
-- expect a boolean response (true/false).

export = {
    -- See the related options in the yaf man page.
    silk = true,
    uniflow = true,
    force_ip6 = false,
    flow_stats = true,
    delta = false,
    mac = true }

-- The "log" variable is optional. Its value must be a table.

log = {
    -- The "spec" keyword may be set to a syslog facility name,
    -- stderr, or the absolute path to a file for file logging.
    -- Default is stderr.
    spec = "/var/log/yaf/yaf.log",

    -- The "level" keyword specifies how much to log. The accepted
    -- values are "quiet", "error", "critical", "warning", "message",
    -- and "debug". Default is "warning".
    level = "debug"}

-- The plugin variable is optional. Its value must be a table of tables.
-- See the yafdhcp man page for the plugin that is provided with yaf.
-- To make configuration easier, specify Lua variables that hold
-- the information for each plugin.

DHCP_PLUGIN = {
    -- The "name" keyword specifies the full path to the plugin
    -- library name to load.
    name = "/usr/local/lib/yaf/dhcp_fp_plugin.la"

    -- The "options" keyword specifies the arguments given to the
    -- plugin.
    -- options =

    -- The "conf" keyword specifies the path to a configuration
    -- file to be given to the plugin, if it requires one.
    -- conf =
}

plugin = {DHCP_PLUGIN}

-- The pcap variable is used to configure yaf's export of PCAP
-- data to files.  The pcap variable is optional; if present, its
-- value must be a table.  See the yaf man page for more
-- information on yaf's PCAP capabilities.

pcap = {
    -- The "path" keyword specifies where yaf will write PCAP files.
    path = "/data/pcap/yafpcap",

    -- The "maxpcap" keyword specifies the maximum file size of a
    -- yaf PCAP file.
    maxpcap = 100,

    -- The "pcap_timer" keyword specifies how often the PCAP file
    -- should be rotated.
    pcap_timer = 300,

    -- The "meta" keyword specifies where to write PCAP meta information.
    meta = "/data/meta/yafmeta"}

The following keywords are optional variables. See the yaf man page for more information.

-- idle_timeout = IDLE_TIMEOUT (integer)
-- Set flow idle timeout in seconds.  Default is 300 seconds (5 min)
-- Setting IDLE_TIMEOUT to 0 creates a flow for each packet.
idle_timeout = 300

-- active_timeout = ACTIVE_TIMEOUT (integer)
-- Set flow active timeout in seconds.  Default is 1800 seconds (30 min)
active_timeout = 1800

-- filter = BPF_FILTER
-- Set Berkeley Packet Filtering (BPF) in YAF with BPF_FILTER.
filter = "port 53"

-- APPLICATION LABELING AND DEEP PACKET INSPECTION OPTIONS
-- Turn on application labeling by setting applabel = true
-- Turn on deep packet inspection by setting dpi = true
-- Read the application labeler/DPI rules file from dpi_rules=
-- If dpi_rules is not set, uses the default location
applabel = true
dpi = true
-- dpi_rules = "/usr/local/etc/yafDPIRules.conf"

-- maxpayload = PAYLOAD_OCTETS (integer)
-- Capture at most PAYLOAD_OCTETS octets from the start of each direction
-- of each flow.  Default is 0.
maxpayload = 1024

-- maxexport = MAX_PAY_OCTETS (integer)
-- Export at most MAX_PAY_OCTETS octets from the start of each direction
-- of each flow from the PAYLOAD_OCTETS given to maxpayload.
-- Default is PAYLOAD_OCTETS if export_payload=true
maxexport = maypayload

-- export_payload = true/false
-- If true, export at most PAYLOAD_OCTETS or MAX_PAY_OCTETS given to
-- maxpayload or maxexport for each direction of the flow.
-- Default is false.
export_payload = false

-- udp_payload = true/false
-- If true, capture at most PAYLOAD_OCTETS octets from the start of
-- each UDP flow, where PAYLOAD_OCTETS is set using the maxpayload option
udp_payload = true

-- stats = INTERVAL (integer)
-- If present, yaf will export process statistics every INTERVAL seconds.
-- If stats is set to 0, no stats records will be exported.
-- default is 300
stats = 300

-- ingress = ingressInterface (integer)
-- egress = egressInterface (integer)
-- use the above options to manually set the ingressInterface or
-- egressInterface in the exported flow record. Default is 0.
ingress = 0
egress = 0

-- obdomain = DOMAIN_ID (integer)
-- Set the othe observationDomainId on each exported IPFIX message to
-- DOMAIN_ID.  Default is 0.
obdomain = 0

-- maxflows = FLOW_TABLE_MAX (integer)
-- Limit the number of open flows to FLOW_TABLE_MAX. Default is no limit.
-- maxflows =

-- maxfrags = FRAG_TABLE_MAX (integer)
-- Limit the number of fragments to FRAG_TABLE_MAX. Default is no limit.
-- maxfrags =

-- udp_uniflow = PORT (integer)
-- If set, export each UDP packet on the given PORT (or 1 for all ports)
-- as a single flow. Default is 0 (off).
udp_uniflow = 0

-- Turn on entropy output by setting entropy = true
entropy = true

-- no_tombstone = true/false
-- If true, tombstone records will not be sent.
-- default is false (that is, to export tombstone records).

-- no_tombstone =

-- tombstone_configured_id = TOMBSTONE_IDENTIFIER (integer)
-- Set the configured identifier for tombstone records generated by YAF.
-- default is 0

-- tombstone_configured_id =

-- no_element_metadata = true/false
-- If true, element metadata (RFC5610 records) will not be sent.
-- default is false (that is, to export the RFC5610 records).

-- no_element_metadata =

-- no_template_metadata = true/false
-- If true, template metadata (name, description, other information) will
-- not be sent
-- default is false (that is, to export template metadata).

-- no_template_metadata =

The following options configure the passive OS fingerprinting capabilities in yaf. This capabliity must be configured when yaf is built.

-- p0fprint = true/false
-- p0f_fingerprints = "/usr/local/etc/p0f.fp"
-- fpexport = true/false
-- See the yaf man page for more information. YAF must be configured
-- appropriately to use the following options.
-- p0fprint = true
-- fpexport = true
-- p0f_fingerprints = "/usr/local/etc/p0f.fp"

The following options configure support for the nDPI application labeler. This capabliity must be configured when yaf is built.

-- nDPI OPTIONS
-- ndpi = true/false
-- ndpi_proto_file = "PATH"
-- See the yaf man page for more information. YAF must be configured
-- appropriately to use the following options.
-- ndpi = true
-- ndpi_proto_file = "LOCATION"

YAF Applabel and DPI Configuration File

This file is described on the Application Labeling and Deep Packet Inspection pages.

YAF Manual Pages

The following manual pages are available and distributed with YAF: