NetFlow & IPFIX – Flow Monitoring and Traffic Analysis
1. What Is NetFlow?
NetFlow is a Cisco-developed protocol that collects and exports metadata about IP traffic flows as packets pass through a router or switch interface. Unlike packet capture (which records the full content of every packet), NetFlow records only the characteristics of each conversation — who talked to whom, using which protocol, for how long, and how much data was exchanged. This makes NetFlow extremely efficient: it provides powerful visibility with low overhead.
NetFlow architecture:
┌──────────────────────────────────────────────────────────────────┐
│ ROUTER / SWITCH (Exporter) │
│ │
│ Packets arrive → Flow cache records 5-tuple + stats │
│ Cache entry expires → Flow record exported to Collector │
└──────────────────────┬───────────────────────────────────────────┘
│ UDP (port 2055 typical)
▼
┌──────────────────────────────────────────────────────────────────┐
│ COLLECTOR (e.g., SolarWinds, ntopng, Elasticsearch) │
│ Receives, stores, and indexes flow records │
└──────────────────────┬───────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ ANALYZER / DASHBOARD │
│ Top talkers, protocol breakdown, anomaly alerts, SIEM feed │
└──────────────────────────────────────────────────────────────────┘
Related pages: show ip route | show interfaces | SNMP Overview | SNMP Versions | Syslog Overview | Syslog Severity | Common Port Numbers | Wireshark | NetFlow Configuration (Lab)
2. What Is a Flow? The 5-Tuple and 7-Tuple
A flow is defined as a unidirectional sequence of IP packets that share the same set of identifying attributes. All packets that belong to the same flow are counted together — accumulating byte counts, packet counts, and timestamps until the flow expires.
5-Tuple (Basic Flow Key)
| Field | Example Value | Why It Matters |
|---|---|---|
| Source IP Address | 192.168.1.10 |
Who initiated the traffic |
| Destination IP Address | 8.8.8.8 |
Where the traffic is going |
| Source Port | 52000 |
Ephemeral port assigned by OS |
| Destination Port | 53 |
Identifies the application/service (DNS=53, HTTP=80, HTTPS=443) |
| Layer 4 Protocol | UDP (17) |
TCP vs UDP vs ICMP |
192.168.1.10:52000 → 8.8.8.8:53 UDPThis represents a single DNS query from a workstation to Google's DNS server. The flow record will accumulate: 1 packet, ~64 bytes, start time, end time.
7-Tuple (Extended Flow Key)
The full NetFlow key adds two more fields to disambiguate flows arriving on different interfaces:
| Additional Field | Purpose |
|---|---|
| Type of Service (ToS / DSCP) | Distinguishes flows with different QoS markings — a voice call on DSCP EF vs bulk data on DSCP CS0, even between the same IP pair |
| Input Interface (ifIndex) | Differentiates flows arriving from different physical interfaces, e.g., two ISP uplinks with different ToS values |
Flow Directionality
Flows are always unidirectional. A TCP connection between PC and server produces two separate flow records — one for each direction:
TCP session: PC (192.168.1.10:54321) ─── TCP ──▶ Server (10.0.0.5:443) → Flow Record A Server (10.0.0.5:443) ──── TCP ──▶ PC (192.168.1.10:54321) → Flow Record B Both records needed to account for full session bandwidth (upload + download)
3. NetFlow Versions
| Version | Year | Key Features | Limitation | Status |
|---|---|---|---|---|
| v1 | 1996 | First implementation; fixed fields; IPv4 only | No BGP AS info; very limited fields | Obsolete — never use in new deployments |
| v5 | 1999 | Fixed 7-tuple fields; includes BGP AS numbers, interface indexes, ToS, TCP flags; widely supported by all collectors | IPv4 only; no IPv6; no MPLS; no variable fields | Most common — still widely deployed; simple and compatible |
| v9 | 2003 | Template-based — flexible field set defined per export; supports IPv6, MPLS, BGP next-hop, VLAN tags, multicast | Slightly more complex to configure; collector must support templates | Current standard — use for IPv6, MPLS, or custom field requirements |
| IPFIX | 2013 | IETF standardisation of NetFlow v9 (RFC 7011); vendor-neutral; supports variable-length fields; enterprise number for private elements | Requires IPFIX-capable collector | Recommended for multi-vendor environments; open standard |
NetFlow v5 Record Fields
NetFlow v5 record (fixed 48-byte format): ┌────────────────┬──────────────────────────────────────────────┐ │ Field │ Description │ ├────────────────┼──────────────────────────────────────────────┤ │ srcaddr │ Source IPv4 address │ │ dstaddr │ Destination IPv4 address │ │ nexthop │ IP address of next-hop router │ │ input │ SNMP ifIndex of input interface │ │ output │ SNMP ifIndex of output interface │ │ dPkts │ Packet count in flow │ │ dOctets │ Total bytes in flow │ │ First │ SysUpTime of first packet (ms) │ │ Last │ SysUpTime of last packet (ms) │ │ srcport │ Source port number │ │ dstport │ Destination port number │ │ tcp_flags │ OR of TCP flags seen in flow │ │ prot │ IP protocol (6=TCP, 17=UDP, 1=ICMP) │ │ tos │ IP Type of Service (ToS) byte │ │ src_as │ BGP autonomous system of source │ │ dst_as │ BGP autonomous system of destination │ │ src_mask │ Prefix length of source subnet │ │ dst_mask │ Prefix length of destination subnet │ └────────────────┴──────────────────────────────────────────────┘
4. Flow Cache: Active and Inactive Timers
The router maintains an in-memory flow cache — a table of all currently active flows. Each entry accumulates statistics for matching packets. Flows are exported to the collector when they expire, triggered by one of three conditions:
| Expiry Condition | Default Timer | Configurable? | When It Fires |
|---|---|---|---|
| Active timer | 30 minutes | Yes — ip flow-cache timeout active 1 |
Long-lived flows (e.g., file transfers) — periodically exports mid-flow records so the collector gets incremental updates rather than waiting for the flow to finish |
| Inactive timer | 15 seconds | Yes — ip flow-cache timeout inactive 15 |
Idle flows — if no new packets match a flow entry for 15 seconds, the flow is exported and removed from the cache |
| Cache full | N/A | Increase cache size | If the flow cache reaches capacity, the oldest flows are forcibly exported to make room for new ones |
| TCP FIN/RST | N/A | N/A | A TCP session teardown (FIN or RST flag) signals the end of a TCP flow — the entry is exported shortly after the teardown is detected |
5. Traditional NetFlow Configuration (Cisco IOS)
The traditional NetFlow configuration (available on IOS 12.x and later) uses interface-level commands to enable flow monitoring and global commands to define the collector destination.
Complete Configuration Example
! ── Step 1: Enable NetFlow on interfaces ───────────────────────────────── interface GigabitEthernet0/0 description WAN-Uplink-ISP1 ip flow ingress ! Monitor inbound traffic ip flow egress ! Monitor outbound traffic interface GigabitEthernet0/1 description LAN-Core-Switch ip flow ingress ip flow egress ! ── Step 2: Configure flow export destination ───────────────────────────── ! Send flows to collector at 192.168.100.10, UDP port 2055 ip flow-export destination 192.168.100.10 2055 ! Specify NetFlow version (v5 for broad compatibility, v9 for IPv6/MPLS) ip flow-export version 5 ! Source flows from a loopback for consistent identification ip flow-export source Loopback0 ! ── Step 3: Optional — tune cache timers ───────────────────────────────── ! Active timer: export active flows every 1 minute (default 30 min) ip flow-cache timeout active 1 ! Inactive timer: export idle flows after 15 seconds (default 15 sec) ip flow-cache timeout inactive 15 ! ── Step 4: Optional — enable flow aggregation ──────────────────────────── ! Aggregate similar flows before export to reduce collector load ip flow aggregation cache destination-prefix enabled ip flow aggregation cache source-prefix enabled ! ── Step 5: Verify ──────────────────────────────────────────────────────── ! Check export configuration Router# show ip flow export ! View active flows in cache Router# show ip cache flow ! View verbose flow output Router# show ip cache verbose flow
show ip cache flow — Reading the Output
Router# show ip cache flow IP packet size distribution (1M total packets): 64 128 256 512 1024 1500 .45 .25 .15 .08 .04 .03 IP Flow Switching Cache, 278544 bytes 3457 active, 61079 inactive, 4982 added Highest flow count: 5892 Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec) -------- ----- ----- ------- ----- ------- ----------- --------- TCP-WWW 14523 3812 789443 1.2G 207 .9 2.5 TCP-Telnet 12 3 23 2K 7 4.1 15.1 UDP-DNS 23891 8210 89123 5.6M 10 .1 .5 ICMP 2134 543 9023 0.7M 16 .2 .5 SrcIf SrcIPaddr DstIf DstIPaddr Pr SrcP DstP Pkts Gi0/0 10.1.1.1 Gi0/1 192.168.1.5 06 C0DB 0050 1234 ← TCP src=49371 dst=80 (HTTP) Gi0/0 10.1.1.2 Gi0/1 8.8.8.8 11 D8A1 0035 89 ← UDP src=55457 dst=53 (DNS) Key: Pr = Protocol (06=TCP, 11=UDP, 01=ICMP) SrcP/DstP = Source/Destination port in HEX (0050 hex = 80 decimal = HTTP) C0DB hex = 49371 decimal (ephemeral port)
6. Flexible NetFlow (FNF) — Modern Cisco IOS Configuration
Flexible NetFlow (FNF) replaced traditional NetFlow on modern Cisco IOS platforms (IOS 12.4(20)T+, IOS-XE, IOS-XR). It uses a modular, policy-based approach: you define exactly which fields to monitor in a flow record, how to export in a flow exporter, and combine them in a flow monitor that is then applied to interfaces.
! ── Flexible NetFlow — full configuration ──────────────────────────────── ! Step 1: Define the flow record (what fields to collect) flow record MY-RECORD description "IPv4 traffic analysis" match ipv4 source address ! Src IP as a flow key field match ipv4 destination address ! Dst IP as a flow key field match transport source-port ! Src port as a flow key field match transport destination-port ! Dst port as a flow key field match ipv4 protocol ! Protocol as a flow key field match interface input ! Input interface as a flow key field collect transport tcp flags ! Non-key: collect TCP flags collect counter bytes ! Non-key: count bytes collect counter packets ! Non-key: count packets collect timestamp sys-uptime first ! Non-key: flow start time collect timestamp sys-uptime last ! Non-key: flow last seen time ! Step 2: Define the flow exporter (where to send data) flow exporter MY-EXPORTER destination 192.168.100.10 transport udp 2055 source Loopback0 export-protocol netflow-v9 ! Use v9 (template-based) template data timeout 60 ! Send templates every 60 seconds ! Step 3: Define the flow monitor (links record + exporter) flow monitor MY-MONITOR record MY-RECORD exporter MY-EXPORTER cache timeout active 60 ! Export active flows every 60 seconds cache timeout inactive 15 ! Export idle flows after 15 seconds ! Step 4: Apply to interfaces interface GigabitEthernet0/0 ip flow monitor MY-MONITOR input ip flow monitor MY-MONITOR output ! Step 5: Verify Router# show flow monitor MY-MONITOR cache Router# show flow exporter MY-EXPORTER statistics Router# show flow record MY-RECORD
match are
key fields — they define the flow identity (different values = different
flows). Fields under collect are non-key fields — they
accumulate statistics within a flow but do not split flows. For example, if
you put collect transport tcp flags, all packets in the same flow
contribute their flags to the collection but a FIN flag does not create a new
flow; it just gets OR'd into the collected TCP flags value.
7. Traffic Analysis — Reading NetFlow Data
Top Talkers — Bandwidth Identification
The most immediate use of NetFlow is identifying which hosts, applications, or destinations consume the most bandwidth. This is called the Top Talkers report.
Example Top Talkers output (from NetFlow collector): Rank Source IP Bytes % Total Protocol Destination ─────────────────────────────────────────────────────────────────── 1 192.168.1.20 8.2 GB 42% TCP/443 151.101.x.x (YouTube CDN) 2 10.0.0.5 5.1 GB 26% TCP/445 10.0.0.100 (File server backup) 3 192.168.1.30 2.3 GB 12% TCP/443 52.x.x.x (Microsoft OneDrive) 4 192.168.1.10 0.8 GB 4% UDP/53 8.8.8.8 (High DNS query rate) 5 10.0.0.99 0.5 GB 3% TCP/6881 Various (BitTorrent P2P — ALERT) Action items: • 192.168.1.20: Apply QoS to limit streaming — see ports.html for port reference • 10.0.0.5: Expected backup traffic — confirm schedule aligns with off-peak hours • 10.0.0.99: Investigate BitTorrent — potential policy violation; apply ACL
Protocol Breakdown
Protocol distribution (last 24 hours): TCP/443 (HTTPS) ████████████████████ 62% TCP/80 (HTTP) ████████ 24% UDP/53 (DNS) ███ 8% UDP/123 (NTP) █ 2% TCP/22 (SSH) █ 2% Unknown 4444 ▌ 0.5% ← Investigate! (common malware port) Other ▌ 1.5%
Anomaly Detection
Sudden deviations from the flow baseline are the primary security signal NetFlow provides. Common patterns:
| Anomaly Pattern | What NetFlow Shows | Likely Cause | Response |
|---|---|---|---|
| DDoS / Flood | Sudden spike to 10,000+ flows/sec from many sources to one destination IP; high packet rate with small packet sizes (UDP/ICMP) | Volumetric DDoS attack targeting your IP | Activate RTBH (Remotely Triggered Black Hole); contact upstream ISP; apply rate-limiting ACL |
| Port Scan | One source IP generates flows to the same destination IP across hundreds of different destination ports in rapid succession; each flow = 1 packet | Attacker or scanner mapping open services on a host | Block scanning IP; alert security team; review firewall rules for exposed services (see Firewall) |
| Botnet C2 | Internal host makes repeated small flows to same external IP on unusual ports (e.g., port 8080, 4444, 6667); flows appear at regular intervals (beaconing) | Infected host checking in with Command & Control server | Isolate infected host; block C2 IP on firewall; incident response |
| Data Exfiltration | Large outbound flows from a database server to an unexpected external IP; high byte count; unusual destination (unknown cloud/hosting provider) | Attacker or malicious insider exfiltrating data | Block destination; alert security; investigate source host |
| Lateral Movement | Internal-to-internal flows; a workstation suddenly generating flows to many other internal hosts on ports like 445 (SMB), 135 (RPC), 22 (SSH) | Compromised host scanning or spreading to other internal systems | Isolate source host; check for worm/ransomware; review ACL for internal segmentation |
8. NetFlow Sampling
On high-speed interfaces (10 Gbps+) or routers with limited CPU, monitoring every single packet is impractical. Sampling instructs the router to examine only a statistical subset of packets — reducing CPU and memory overhead at the cost of some accuracy.
! Traditional sampling — 1 in every 100 packets analysed interface GigabitEthernet0/0 ip route-cache flow sampled ip flow-sampling-mode packet-interval 100 ! Sample 1 of every 100 packets ! Flexible NetFlow sampler sampler MY-SAMPLER mode random 1 out-of 100 ! Random sampling — 1 packet per 100 (1%) flow monitor MY-MONITOR record MY-RECORD exporter MY-EXPORTER sampler MY-SAMPLER ! Attach sampler to the monitor
| Sampling Rate | CPU Impact | Accuracy | Typical Use |
|---|---|---|---|
| 1:1 (no sampling) | Highest — every packet processed | 100% — exact flow data | Low-speed interfaces (<1 Gbps); security monitoring |
| 1:10 (10%) | Moderate reduction | High — good for security analysis | 1–10 Gbps interfaces; balance accuracy and performance |
| 1:100 (1%) | Low — suitable for high-speed links | Statistical — good for bandwidth trending | 10–40 Gbps interfaces; capacity planning and top-talker reports |
| 1:1000 (0.1%) | Very low | Coarse — misses short-lived flows | 100 Gbps+ backbone links; aggregate trend analysis only |
9. NetFlow vs sFlow vs IPFIX vs J-Flow
| Protocol | Standard | Vendor | Sampling | IPv6 / MPLS | Key Difference |
|---|---|---|---|---|---|
| NetFlow v5 | Cisco proprietary | Cisco | Optional | No | Fixed fields; most widely understood; IPv4 only; no templates |
| NetFlow v9 | Cisco / IETF basis | Cisco | Optional | Yes | Template-based; flexible fields; foundation for IPFIX |
| IPFIX | IETF RFC 7011 (open) | Multi-vendor | Optional | Yes | Vendor-neutral standardisation of v9; variable-length fields; enterprise-specific elements; preferred for new deployments |
| sFlow | RFC 3176 (open) | HP, Juniper, Arista | Always (required) | Yes | Samples packets AND includes a portion of the actual packet payload (up to 128 bytes) — provides some Layer 7 context but is always sampled; no exact flow records; lower CPU than NetFlow |
| J-Flow | Juniper proprietary | Juniper | Optional | Yes | Juniper's equivalent to NetFlow v5/v9; exports to same collectors; supports Junos-specific fields |
| NetStream | Huawei proprietary | Huawei | Optional | Yes | Huawei's NetFlow equivalent; compatible with most NetFlow collectors when using v9/IPFIX format |
10. NetFlow vs Packet Capture
| Feature | NetFlow / IPFIX | Packet Capture (Wireshark / tcpdump) |
|---|---|---|
| Data captured | Flow metadata only — no payload content | Full packet including headers AND payload |
| Privacy / compliance | High — no user data captured; safe for long-term retention | Low — captures all data including credentials, emails, files |
| Storage requirement | Very low — ~100–300 bytes per flow regardless of traffic volume | Very high — 1 Gbps interface generates ~450 GB/hour of capture data |
| Router/switch impact | Low CPU overhead (especially with sampling) | High — requires SPAN/mirror port; dedicated capture appliance |
| Retention period | Months to years — flow data is compact enough for long retention | Hours to days at most — storage constraints |
| What you can answer | Who talked to whom? How much? When? Which protocol? Top talkers? DDoS? Port scan? Beaconing? | What exactly was said? What data was transferred? Protocol decode? Application-level debugging? |
| Typical use | Continuous network-wide monitoring; security analytics; capacity planning; compliance; billing | Targeted troubleshooting of specific issues; malware analysis; application debugging |
11. SIEM Integration
NetFlow data fed into a SIEM (Security Information and Event Management) system provides the traffic context that complements log data from syslog and SNMP. Together they give a complete security picture: SIEM correlates flow anomalies with authentication events, firewall logs, and threat intelligence feeds.
! Splunk — NetFlow queries (Splunk indexes flow data from collector) ! Find top bandwidth consumers in last hour: index=netflow earliest=-1h | stats sum(bytes) as total_bytes by src_ip | sort -total_bytes | head 10 ! Detect port scans (one source, many destinations or ports): index=netflow earliest=-15m | stats dc(dest_port) as unique_ports by src_ip dest_ip | where unique_ports > 50 | sort -unique_ports ! Find beaconing (periodic connections to same external IP): index=netflow dest_ip!=RFC1918 | bucket _time span=1m | stats count by src_ip dest_ip _time | streamstats count as connection_number by src_ip dest_ip | eventstats stdev(count) as variability by src_ip dest_ip | where variability < 2 ! Very consistent — likely automated beaconing ! Detect large outbound data transfers (potential exfiltration): index=netflow dest_ip!=RFC1918 | stats sum(bytes) as outbound_bytes by src_ip dest_ip | where outbound_bytes > 100000000 ! > 100 MB outbound | sort -outbound_bytes
12. Practical Use Cases
| Use Case | What NetFlow Provides | Action Taken |
|---|---|---|
| WAN link saturation | Top Talkers report shows 192.168.1.20 using 60% of WAN bandwidth on TCP/443 (streaming video) | Apply QoS policy to rate-limit streaming traffic; inform user; consider SD-WAN for application-aware routing |
| Security incident response | Internal host 10.0.0.55 making 500 flows/minute to 50 different external IPs on TCP/4444 | Isolate host from network; trigger incident response; forensic analysis; block C2 IPs on firewall |
| Capacity planning | NetFlow trend data shows WAN utilisation growing 15% per month; current 100 Mbps link will saturate in 4 months | Initiate upgrade procurement; justify with flow trend data |
| Billing / chargeback | Aggregated flow data by department VLAN shows IT consumed 8 TB, Finance 2 TB, Sales 1 TB last month | Internal chargeback billing; identify departments for cost conversations |
| DDoS mitigation | Spike to 50,000 flows/sec targeting one public IP; all flows have small packet sizes and come from thousands of source IPs | Activate RTBH to drop traffic to victim IP upstream; engage DDoS scrubbing service; notify ISP |
| Application visibility | Unknown flows on port 6881 (BitTorrent) from multiple workstations; confirmed policy violation | Apply ACL to block P2P ports; notify HR; document in security policy |
13. Troubleshooting NetFlow
| Symptom | Likely Cause | Diagnostic & Fix |
|---|---|---|
| No flows appearing in collector | Export destination not configured; UDP 2055 blocked by firewall; wrong collector IP | show ip flow export — verify destination IP and port;
verify UDP 2055 is not blocked between router and collector;
check collector is listening on correct port |
| Partial flows only — some traffic missing | ip flow ingress applied to some interfaces but not all;
only inbound or outbound flows captured |
Apply both ip flow ingress and ip flow egress
on all relevant interfaces; check all WAN and LAN interfaces |
| High router CPU from NetFlow | Unsampled NetFlow on very high-speed interfaces; flow cache full | Enable sampling (ip flow-sampling-mode packet-interval 100);
increase flow cache size; reduce active timer to export flows sooner |
| Flows missing IPv6 traffic | Using NetFlow v5 — does not support IPv6 | Upgrade to NetFlow v9 or IPFIX; use Flexible NetFlow with IPv6 match fields |
| Collector receiving templates but no data | Using NetFlow v9/IPFIX — templates sent first; data records only sent after cache expiry | Wait for active timer expiry (default 30 min); reduce
cache timeout active to 1 minute to receive data sooner |
| Flow byte counts much lower than interface counters | Sampling enabled — byte count represents sampled subset, not total | Multiply by sampling rate (e.g., 1:100 sample = multiply bytes by 100 to estimate actual total); disable sampling if exact counts needed |
14. Key Points & Exam Tips
- NetFlow collects flow metadata — not packet payload. A flow = unidirectional sequence of packets sharing the same 5-tuple: Src IP, Dst IP, Src Port, Dst Port, Protocol.
- 7-tuple extends the key with ToS and Input Interface.
- Flow architecture: Exporter (router) → Collector (server) → Analyzer (dashboard).
- NetFlow export uses UDP port 2055 by default (configurable).
- v5: Fixed fields, IPv4 only, most compatible. v9: Template-based, IPv6/MPLS support. IPFIX: Open standard (RFC 7011), vendor-neutral, based on v9.
- Flows expire via active timer (default 30 min — long-lived flows), inactive timer (default 15 sec — idle flows), or TCP FIN/RST.
- Flexible NetFlow (FNF): flow record (fields to collect) + flow exporter (destination) + flow monitor (links them) applied to interface.
- Sampling reduces CPU by only processing 1 in N packets
(
mode random 1 out-of 100). Reduces security detection capability for short-lived flows. - Security uses: top talkers (bandwidth hogs), port scan detection (many ports, single source), botnet beaconing (regular intervals to same external IP), DDoS detection (sudden flow rate spike), data exfiltration (large unexpected outbound flows).
show ip cache flow— view active flows and statistics.show ip flow export— verify collector configuration.show flow monitor <name> cache— FNF flows.- IPFIX = IP Flow Information Export (RFC 7011) — the IETF standardisation of NetFlow v9.
Related pages: Wireshark | SNMP Overview | SNMP Versions | Syslog Overview | Syslog Severity | show interfaces | Firewalls | Applying ACLs | NetFlow Lab Configuration | Syslog Configuration Lab | SNMP v2c/v3 Configuration Lab