Customizing Flexible NetFlow Flow Records and Flow Monitors
Last Updated: November 29, 2012
This document contains information about and instructions for customizing Cisco IOS Flexible NetFlow flow records and flow monitors. If the tasks and configuration examples in the "Getting Started with Configuring Cisco IOS Flexible NetFlow" module and the "Configuring Cisco IOS Flexible NetFlow with Predefined Records" module were not suitable for your traffic analysis requirements, you can use the information and instructions in this document to customize Flexible NetFlow to meet your traffic analysis requirements.
NetFlow is a Cisco IOS technology that provides statistics on packets flowing through a router. NetFlow is the standard for acquiring IP operational data from IP networks. NetFlow provides data to support network and security monitoring, network planning, traffic analysis, and IP accounting.
Flexible NetFlow improves on original NetFlow by adding the capability to customize the traffic analysis parameters for your specific requirements. Flexible NetFlow facilitates the creation of more complex configurations for traffic analysis and data export through the use of reusable configuration components.
Your software release may not support all the features documented in this module. For the latest caveats and feature information, see
Bug Search Tool and the release notes for your platform and software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the feature information table at the end of this module.
Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to
www.cisco.com/go/cfn. An account on Cisco.com is not required.
Prerequisites for Customizing Flexible NetFlow Flow Records and Flow Monitors
You are familiar with the information in the " Cisco IOS Flexible NetFlow Overview " module.
You are familiar with the Flexible NetFlow key fields as they are defined in the following commands in the
Cisco IOS Flexible NetFlow Command Reference :
matchflow
matchinterface
match {ipv4 |
ipv6}
matchrouting
matchtransport
You are familiar with the Flexible NetFlow nonkey fields as they are defined in the following commands in the
Cisco IOS Flexible NetFlow Command Reference :
collectcounter
collectflow
collectinterface
collect{ipv4 |
ipv6}
collectrouting
collecttimestampsys-uptime
collecttransport
The networking device must be running a Cisco IOS release that supports Flexible NetFlow.
IPv4 Traffic
The networking device must be configured for IPv4 routing.
One of the following must be enabled on your router and on any interfaces on which you want to enable Flexible NetFlow: Cisco Express Forwarding or distributed Cisco Express Forwarding.
IPv6 Traffic
The networking device must be configured for IPv6 routing.
One of the following must be enabled on your router and on any interfaces on which you want to enable Flexible NetFlow: Cisco Express Forwarding IPv6 or distributed Cisco Express Forwarding.
Information About Customizing Flexible NetFlow Flow Records and Flow Monitors
Criteria for Identifying Traffic To Be Used in Analysis in Flexible NetFlow
If the predefined Flexible NetFlow records are not suitable for your traffic requirements, you can create a user-defined (custom) record using the Flexible NetFlow collect and match commands. Before you can create a customized record, you must decide the criteria that you are going to use for the key and nonkey fields.
If you want to create a customized record for detecting network attacks, you must include the appropriate key and nonkey fields in the record to ensure that the router creates the flows and captures the data that you need to analyze the attack and respond to it. For example, SYN flood attacks are a common denial of service (DoS) attack in which TCP flags are used to flood open TCP requests to a destination host. When a normal TCP connection starts, a destination host receives a SYN (synchronize/start) packet from a source host and sends back a SYN ACK (synchronize acknowledge). The destination host must then hear an ACK (acknowledge) of the SYN ACK before the connection is established. This is referred to as the "TCP three-way handshake." While the destination host waits for the ACK to the SYN ACK, a connection queue of finite size on the destination host keeps track of connections waiting to be completed. This queue typically empties quickly because the ACK is expected to arrive a few milliseconds after the SYN ACK. The TCP SYN attack exploits this design by having an attacking source host generate TCP SYN packets with random source addresses toward a victim host. The victim destination host sends a SYN ACK back to the random source address and adds an entry to the connection queue. Because the SYN ACK is destined for an incorrect or nonexistent host, the last part of the TCP three-way handshake is never completed and the entry remains in the connection queue until a timer expires, typically for about one minute. Rapid generation by the source of TCP SYN packets from random IP addresses can fill the connection queue and cause denial of TCP services (such as e-mail, file transfer, or WWW) to legitimate users.
The information needed for a security monitoring record for this type of DoS attack might include the following key and nonkey fields:
Key fields:
Destination IP address or destination IP subnet
TCP flags
Packet count
Nonkey fields
Destination IP address
Source IP address
Interface input and output
Tip
Many users configure a general Flexible NetFlow monitor that triggers a more detailed Flexible NetFlow view of a DoS attack using these key and nonkey fields.
How to Customize Flexible NetFlow Flow Records and Flow Monitors
Note
Only the keywords and arguments required for the Flexible NetFlow commands used in these tasks are explained in these tasks. For information about the other keywords and arguments available for these Flexible NetFlow commands, refer to the
Cisco IOS Flexible NetFlow Command Reference.
Perform this task to configure a customized flow record.
Customized flow records are used to analyze traffic data for a specific purpose. A customized flow record must have at least one
match criterion for use as the key field and typically has at least one
collect criterion for use as a nonkey field.
There are hundreds of possible permutations of customized flow records. This task shows the steps that are used to create one of the possible permutations. Modify the steps in this task as appropriate to create a customized flow record for your requirements.
6. Repeat Step 5 as required to configure additional key fields for the record.
7.collectinterface {input |
output}
8. Repeat Step 7 as required to configure additional nonkey fields for the record.
9.end
10.showflowrecordrecord-name
11.showrunning-configflowrecordrecord-name
DETAILED STEPS
Command or Action
Purpose
Step 1
enable
Example:
Device> enable
Enables privileged EXEC mode.
Enter your password if prompted.
Step 2
configureterminal
Example:
Device# configure terminal
Enters global configuration mode.
Step 3
flowrecordrecord-name
Example:
Device(config)# flow record FLOW-RECORD-1
Creates a flow record and enters Flexible NetFlow flow record configuration mode.
This command also allows you to modify an existing flow record.
Step 4
descriptiondescription
Example:
Device(config-flow-record)# description Used for basic traffic analysis
(Optional) Creates a description for the flow record.
Step 5
match {ipv4 |
ipv6}{destination |
source}
address
Example:
Device(config-flow-record)# match ipv4 destination address
Configures a key field for the flow record.
Note
This example configures the IPv4 destination address as a key field for the record. For information about the other key fields available for the
matchipv4 command, and the other
match commands that are available to configure key fields, refer to the
Cisco IOS Flexible NetFlow Command Reference .
Step 6
Repeat Step 5 as required to configure additional key fields for the record.
Configures the input interface as a nonkey field for the record.
Note
This example configures the input interface as a nonkey field for the record. For information on the other
collect commands that are available to configure nonkey fields, refer to the
Cisco IOS Flexible NetFlow Command Reference.
Step 8
Repeat Step 7 as required to configure additional nonkey fields for the record.
--
Step 9
end
Example:
Device(config-flow-record)# end
Exits Flexible NetFlow flow record configuration mode and returns to privileged EXEC mode.
Step 10
showflowrecordrecord-name
Example:
Device# show flow record FLOW_RECORD-1
(Optional) Displays the current status of the specified flow record.
Step 11
showrunning-configflowrecordrecord-name
Example:
Device# show running-config flow record FLOW_RECORD-1
(Optional) Displays the configuration of the specified flow record.
Creating a Customized Flow Monitor
Perform this required task to create a customized flow monitor.
Each flow monitor has a separate cache assigned to it. Each flow monitor requires a record to define the contents and layout of its cache entries.
Before You Begin
If you want to use a customized record instead of using one of the Flexible NetFlow predefined records, you must create the customized record before you can perform this task.
If you want to add a flow exporter to the flow monitor for data export, you must create the exporter before you can complete this task.
Note
You must use the
noipflowmonitor command to remove a flow monitor from all of the interfaces to which you have applied it before you can modify the parameters for the
record command on the flow monitor. For information about the
ipflowmonitor command, refer to the
Cisco IOS Flexible NetFlow Command Reference.
Example: Configuring a Permanent Flow Record Cache with a Limited Number of Flows
The following example is designed to monitor the type of service (ToS) field usage on all interfaces in the router. An exporter is not configured because this example is intended to be used to capture additional data for analysis on the router using the
showflowmonitorcommand.
This example starts in global configuration mode.
!
ip cef
!
flow record QOS_RECORD
description UD: Flow Record to monitor the use of TOS within this router/network
match interface input
match interface output
match ipv4 tos
collect counter packets
collect counter bytes
exit
!
flow monitor QOS_MONITOR
description UD: Flow Monitor which watches the limited combinations of interface and TOS
record QOS_RECORD
cache type permanent
cache entries 8192 ! 2^5 (combos of interfaces) * 256 (values of TOS)
exit
!
interface ethernet0/0
ip flow monitor QOS_MONITOR input
exit
!
interface ethernet0/1
ip flow monitor QOS_MONITOR input
exit
!
interface ethernet0/2
ip flow monitor QOS_MONITOR input
exit
!
interface serial2/0
ip flow monitor QOS_MONITOR input
exit
!
interface serial2/1
ip flow monitor QOS_MONITOR input
!
The display from the
showflowmonitor command shows the current status of the cache.
Router# show flow monitor QOS_MONITOR cache
Cache type: Permanent
Cache size: 8192
Current entries: 2
High Watermark: 2
Flows added: 2
Updates sent ( 1800 secs) 0
Example: Configuring a Customized Flow Record Cache for Monitoring IPv6 Traffic
The following example creates a customized flow record cache for monitoring IPv6 traffic.
This example starts in global configuration mode.
!
ip cef
ipv6 cef
!
flow record FLOW-RECORD-2
description Used for basic IPv6 traffic analysis
match ipv6 destination address
collect counter bytes
collect counter packets
!
flow monitor FLOW-MONITOR-2
description Used for basic IPv6 traffic analysis
record FLOW-RECORD-2
cache entries 1000
!
interface GigabitEthernet0/0/0
ipv6 address 2001:DB8:2:ABCD::2/48
ipv6 flow monitor FLOW-MONITOR-2 input
!
interface GigabitEthernet1/0/0
ipv6 address 2001:DB8:3:ABCD::1/48
ipv6 flow monitor FLOW-MONITOR-2 output
!
Example: Configuring Flexible NetFlow for Monitoring MAC and VLAN Statistics
The following example shows how to configure Flexible NetFlow for monitoring MAC and VLAN statistics.
This sample starts in global configuration mode:
!
flow record LAYER-2-FIELDS-1
match ipv4 source address
match ipv4 destination address
match datalink dot1q vlan output
match datalink mac source address input
match datalink mac source address output
match datalink mac destination address input
match flow direction
!
exit
!
!
flow monitor FLOW-MONITOR-4
record LAYER-2-FIELDS-1
exit
!
ip cef
!
interface GigabitEthernet0/0/1
ip address 172.16.6.2 255.255.255.0
ip flow monitor FLOW-MONITOR-1 input
!
Example: Configuring Flexible NetFlow for Ingress VRF Support
The following example configures the collection of the virtual routing and forwarding (VRF) ID from incoming packets on a router by applying an input flow monitor having a flow record that collects the VRF ID as a key field.
This sample starts in global configuration mode:
!
flow record rm_1
match routing vrf input
match ipv4 source address
match ipv4 destination address
collect interface input
collect interface output
collect counter packets
!
flow monitor mm_1
record rm_1
!
interface Serial2/0
ip vrf forwarding green
ip address 172.16.2.2 255.255.255.252
ip flow monitor mm_1 output
!
end
Example: Configuring Flexible NetFlow for Network-Based Application Recognition
The following example uses Network-based Application recognition (NBAR) to create different flows for each application seen between any two IP hosts by applying a flow monitor having a flow record that collects the application name as a key field.
This sample starts in global configuration mode:
!
flow record rm_1
match application name
match ipv4 source address
match ipv4 destination address
collect interface input
collect interface output
collect counter packets
!
flow monitor mm_1
record rm_1
!
interface FastEthernet0/0
ip address 172.16.2.2 255.255.255.0
ip flow monitor mm_1 input
!
end
Example: Configuring Flexible NetFlow for CTS Fields
This following example configures the collection of the Cisco TrustSec (CTS) fields, source Security Group Tag (SGT) and destination Security Group Tag (DGT), in IPv4 traffic.
This sample starts in global configuration mode:
!
flow exporter EXPORTER-1
destination 172.16.10.2
transport udp 90
exit
flow record rm_1
match ipv4 protocol
match ipv4 source address
match ipv4 destination address
match transport source-port
match transport destination-port
match flow direction
match flow cts source group-tag
match flow cts destination group-tag
collect routing source as
collect routing destination as
collect routing source as peer
collect routing destination as peer
collect routing next-hop address ipv4
collect routing next-hop address ipv4 bgp
collect ipv4 source prefix
collect ipv4 source mask
collect ipv4 destination prefix
collect ipv4 destination mask
collect interface input
collect interface output
collect counter bytes
collect counter packets
collect timestamp sys-uptime first
collect timestamp sys-uptime last
!
flow monitor mm_1
record rm_1
exporter EXPORTER-1
!
interface FastEthernet0/0
ip address 172.16.2.2 255.255.255.0
ip flow monitor mm_1 input
!
end
Where to Go Next
If you want to configure data export for Flexible NetFlow, refer to the "Configuring Data Export for
Cisco IOS Flexible NetFlow with Flow Exporters" module.
If you want to configure flow sampling to reduce the CPU overhead of analyzing traffic, refer to the "Using
Cisco IOS Flexible NetFlow Flow Sampling to Reduce the CPU Overhead of Analyzing Traffic" module.
If you want to configure any of the predefined records for Flexible NetFlow, refer to the "Configuring
Cisco IOS Flexible NetFlow with Predefined Records" module.
The Cisco Support and Documentation website provides online resources to download documentation, software, and tools. Use these resources to install and configure the software and to troubleshoot and resolve technical issues with Cisco products and technologies. Access to most tools on the Cisco Support and Documentation website requires a Cisco.com user ID and password.
The following table provides release information about the feature or features described in this module. This table lists only the software release that introduced support for a given feature in a given software release train. Unless noted otherwise, subsequent releases of that software release train also support that feature.
Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to
www.cisco.com/go/cfn. An account on Cisco.com is not required.
Table 1
Feature Information for Flexible NetFlow
Feature Name
Releases
Feature Information
Flexible NetFlow
12.2(33)SRC
12.2(50)SY
12.4(9)T
15.0(1)SY
15.0(1)SY1
Flexible NetFlow is introduced.
Support for this feature was added for Cisco 7200 series routers in Cisco IOS Release 12.2(33)SRC.
Support for this feature was added for Cisco 7200 and 7300 Network Processing Engine (NPE) series routers in Cisco IOS Release 12.2(33)SRE.
The following commands were introduced or modified:
collectrouting,
debugflowrecord,
matchrouting,
record,
showflowmonitor,showflowrecord,
collectipv6,
collectipv6destination,
collectipv6extensionmap,
collectipv6fragmentation,
collectipv6hop-limit,
collectipv6length,
collectipv6section,
collectipv6source,
collecttransporticmpipv6,
ipv6flowmonitor,
matchipv6,
matchipv6destination,
matchipv6extensionmap,
matchipv6fragmentation,
matchipv6hop-limit,
matchipv6length,
matchipv6section,
matchipv6source,
matchtransporticmpipv6.
Flexible NetFlow--Ingress VRF Support
12.2(33)SRE
12.2(50)SY
15.0(1)M
15.0(1)SY
15.0(1)SY1
Enables collecting the virtual routing and forwarding (VRF) ID from incoming packets on a router by applying an input flow monitor having a flow record that collects the VRF ID as a key or a nonkey field.
Support for this feature was added for Cisco 7200 and 7300 Network Processing Engine (NPE) series routers in Cisco IOS Release 12.2(33)SRE.
The following commands were introduced or modified:
collectrouting,matchrouting,option(FlexibleNetFlow),showflowmonitor.
Flexible NetFlow--NBAR Application Recognition
15.0(1)M
Network-based Application recognition (NBAR) enables creation of different flows for each application seen between any two IP hosts by applying a flow monitor having a flow record that collects the application name as a key or a nonkey field.
The following commands were introduced or modified:
Enables Flexible NetFlow to collect Cisco Trusted Security (CTS) information in IPv4 traffic.
The following commands were introduced or modified:
collectflow,matchflow,showflowmonitor.
TrustSec NetFlow IPv6 SGACL Deny and Drop ExportS
12.2(50)SY
15.0(1)SY
15.0(1)SY1
Enables Flexible NetFlow to collect Cisco Trusted Security (CTS) information in IPv6 traffic.
The following commands were introduced or modified:
collectflow,matchflow,showflowmonitor.
Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL:
www.cisco.com/go/trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1110R)
Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.