NetFlow - jibingl/CCNA-CCNP GitHub Wiki
| Version | Description/Key Features | IPv4 | IPv6 | MPLS | Template-Based | Status |
|---|---|---|---|---|---|---|
| v1 | Original implementation | Yes | No | No | No | Obsolete |
| v5 | Fixed-format, industry standard | Yes | No | No | No | Legacy (Used) |
| v7 | Catalyst switch focus, similar to v5 | Yes | No | No | No | Obsolete |
| v8 | Router-based aggregation | Yes | No | No | No | Obsolete |
| v9 | Flexible NetFlow (FNF), template-based | Yes | Yes | Yes | Yes | Current |
| v10 | IPFIX (IETF Standard) | Yes | Yes | Yes | Yes | Current |
Components of A NetFlow Monitoring Setup
NetFlow_Enabled
HOST_A ------------------ ( ROUTER ) --------------------------- HOST_B
| Flow Exporter
|
`--> Flow Collector <--- Flow Analyzer
- Flow Exporter: Aggregates packets into flow records and exports towards one or more flow collectors.
- Flow Collector: Responsible for reception, storage and pre-processing.
- Flow Analyzer: Analyzes received flow data in the context of intrusion detection or traffic profiling, for example.
Cisco NetFlow v9.0
NetFlow Version 9 Export Packet
+---------------+------------------+--------------+--------+------------------+--------------+
| Packet Header | Template FlowSet | Data FlowSet | ...... | Template FlowSet | Data FlowSet |
+---------------+------------------+--------------+--------+------------------+--------------+
Packet Header Format
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version (0x0009) | Count (total flowsets) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| System Uptime (since booted) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| UNIX Seconds (since 1-1-1970) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Package Sequence |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Packet FlowSet Format
Template & Data FlowSet Example FlowSet
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ start_of_template +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FlowSet ID = 0 (0~255) | | FlowSet ID = 0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length (this flowset) | | Length = 20 bytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Template ID (>255) | | Template ID = 256 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field Count | | Field Count = 3 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field 1 Type | | IPv4_SRCADDR (0x0008) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field 1 Length | | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field 2 Type | | IPv4_DSTADDR (0x000C) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ...... | | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field n Type | | IPv4_NEX_HOP (0x000E) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Field n Length | | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ start_of_data +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FlowSet ID = template_id | | FlowSet ID = 256 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length (this flowset) | | Length = 28 bytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Record 1 - Field 1 value | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 192.168.1.10 | Field 1
| ...... | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Record 1 - Field n value | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 172.16.0.100 | Field 2
| Record 2 - Field 1 value | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ...... | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 192.168.1.1 | Field 3
| Record 2 - Field n value | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
7 Pre-defined Key Fields of NetFlow
(If one field is different, a new flow is created in the flow cache.)
- Source IP address
- Destination IP address
- Source port number
- Destination port number
- Layer 3 protocol type (ex. TCP, UDP)
- Type of service (ToS)
- Input/Ingress interface
Flexible NetFlow
- Define custom fields other than the 7 key fields.
- Uses multiple flow monitors on the same traffic.
- Multiple flow policies separate data outputs.
NetFlow Secure Event Logging (NSEL)
- Stateful Tracking: NSEL tracks the entire lifecycle of a flow, from creation to teardown.
- Event Driven: It logs critical events - flow-create, flow-teardown, flow-denied, and flow-update.
- Treats bidirectional traffic as a single flow.
- Delays the export of flow-create events to reduce unnecessary log entries by preventing the export of data for very short-lived flows.
Configuration Example
Cisco c8000v
flow record lab-ipv4 //(Optional) Create a Flow Record with custom fields
match ipv4 source address //Custom field - source ipv4 address
match ipv4 destination address //Custom field - destination ipv4 address
match ipv4 protocol
collect counter bytes
collect timestamp absolute first
!
flow exporter lab-ipv4 //Configure a Flow Exporter
destination 172.31.100.10 //IP of the Flow Exporter
source GigabitEthernet26 //The interface enable NetFlow monitor
transport udp 2055 //NetFlow UDP port
!
flow monitor lab-ipv4 //Create a Flow Monitor to bind/map the Flow Record & Flow Exporter
record lab-ipv4
exporter lab-ipv4
cache timeout inactive 20
cache timeout active 60
!
sampler lab-ipv4 //Configure a Sampler to reduce the CPU and memory load
mode random 1 out-of 100 //Pick a random packet from 100 packets
!
!
interface GigabitEthernet26
ip flow monitor lab-ipv4 sampler lab-ipv4 output //Apply the Flow Monitor & Sampler to the monitored (source) interface
ip address 172.31.100.21 255.255.255.0
negotiation auto