NetFlow là gì?
NetFlow là giao thức mạng do Cisco phát triển, thu thập metadata về các "flow" (luồng) IP đi qua thiết bị mạng (router, switch, firewall). Một flow = bộ 5-tuple: Source IP, Destination IP, Source Port, Destination Port, Protocol (+ Type of Service, Input/Output Interface).
Khác với PCAP (full packet capture), NetFlow chỉ lưu metadata thống kê: số gói tin, byte, thời gian bắt đầu/kết thúc, flags TCP - không lưu payload (nội dung gói tin).
Cách NetFlow hoạt động
- Thiết bị NetFlow-enabled (router/switch/firewall) nhận gói tin
- Kiểm tra flow cache: Nếu khớp 5-tuple → cập nhật counter (packets, bytes, timestamp)
- Nếu không khớp → tạo flow record mới
- Flow hết hiệu lực (timeout active/inactive) hoặc TCP FIN/RST → Export flow record đến NetFlow Collector
- Collector lưu trữ, phân tích, hiển thị dashboard, báo cáo
Phiên bản NetFlow phổ biến
- v5: Cố định, chỉ IPv4, phổ biến nhất
- v9: Mẫu (template-based), hỗ trợ IPv6, MPLS, VLAN, extensible
- IPFIX (IP Flow Information Export): Chuẩn IETF (RFC 7011), dựa trên v9, vendor-neutral
- sFlow: Sampling-based (không phải flow-based), nhẹ hơn, dùng cho high-speed
Lợi ích của NetFlow cho An ninh mạng
| Lợi ích | Mô tả |
| Phát hiện bất thường (Anomaly Detection) | Baseline traffic bình thường → Cảnh báo: spike traffic, kết nối lạ, port scan, DDoS, beaconing C2, data exfil |
| Forensics & Incident Response | Truy vết: Ai nói với ai, khi nào, bao nhiêu data, port nào, protocol nào - không cần full PCAP |
| Threat Hunting | Truy vấn lịch sử: "Tìm mọi kết nối tới IP độc hại này 30 ngày qua", "Tìm traffic Tor/I2P", "Tìm DNS tunneling" |
| Network Visibility | Top talkers, top protocols, ứng dụng tiêu tốn băng thông, shadow IT, rogue device |
| Capacity Planning | Xu hướng băng thông, upgrade link, QoS, cost optimization |
| Compliance & Auditing | Chứng minh segmentation hoạt động, không traffic trái phép giữa zone, log retention |
| Chi phí thấp hơn PCAP | Lưu trữ 1-5% dung lượng so với full packet capture, giữ được 30-90+ ngày |
NetFlow trong Cisco Cyber Threat Defense (CTD)
- Stealthwatch (nay Cisco Secure Network Analytics) dùng NetFlow làm nguồn dữ liệu chính
- Machine Learning baseline hành vi host/network → Phát hiện: Compromised host, Insider threat, Lateral movement, Crypto mining
- Tích hợp Threat Intelligence: So sánh IP/Domain với Talos reputation
Thông tin trong một NetFlow Record
- Source IP, Destination IP
- Source Port, Destination Port
- Layer 3 Protocol (TCP=6, UDP=17, ICMP=1...)
- Type of Service (ToS) / DSCP
- Input Interface (SNMP ifIndex), Output Interface
- Packets count, Bytes count
- Start Time, End Time (sysUptime milliseconds)
- TCP Flags (cumulative OR của tất cả flags trong flow)
- Next Hop IP, BGP AS Number (source/destination), Subnet Mask
- v9/IPFIX: VLAN ID, MPLS Label, IPv6, ICMP Type/Code, HTTP Host/User-Agent (nếu DPI)
NetFlow vs Full PCAP
| Tiêu chí | NetFlow | Full PCAP |
| Dung lượng lưu trữ | Rất nhỏ (1-5% PCAP) | Rất lớn (TB/ngày cho 10Gbps) |
| Thời gian lưu giữ | 30-365+ ngày | Hours-đays (cần storage lớn) |
| Nội dung (Payload) | Không có | Có đầy đủ |
| Phân tích ứng dụng (L7) | Hạn chế (cần Flexible NetFlow + DPI) | Đầy đủ |
| Phát hiện malware/C2 | Tốt cho behavioral, metadata | Tốt cho signature, payload analysis |
| Latency phân tích | Real-time/near real-time | Chậm (cần index, decode) |
Kết luận: Dùng CẢ HAI: NetFlow cho visibility rộng, lâu dài, real-time; PCAP cho điều tra sâu (deep dive) khi có alert.
NetFlow Components (Thành phần)
- Exporter: Router/Switch/Firewall sinh flow record → Export UDP (port 2055, 9995, 4739...)
- Collector: Nhận, lưu trữ, pre-process flow data (nProbe, ntopng, Splunk, Elastic, Kafka...)
- Analyzer/Application: Dashboard, alerting, reporting, threat hunting UI (Stealthwatch, Scrutinizer, Plixer, Kentik, SolarWinds, ManageEngine, Graylog + NetFlow module...)
NetFlow có mã hóa không?
- NetFlow v5/v9/IPFIX truyền qua UDP không mã hóa → Dễ bị sniff, spoof
- Khuyến nghị: Chạy trên management VRF/out-of-band network, hoặc dùng IPsec/GRE tunnel, hoặc DTLS (IPFIX over DTLS - RFC 7012)
- Kentik, Plixer hỗ trợ nhận NetFlow qua Private Network Interconnect (PNI) tại Equinix
Có cần NetFlow không?
CÓ nếu: Bạn quản trị mạng doanh nghiệp, ISP, Data Center, Cloud, cần visibility, troubleshooting, security monitoring, capacity planning, compliance. Thay thế: sFlow (high-speed sampling), Streaming Telemetry (gNMI, Model-driven - hiện đại hơn, real-time, structured data).
Phân tích NetFlow (NetFlow Analysis)
- Top N: Talkers, Listeners, Protocols, Ports, ASN, Countries
- Time-series: Bandwidth, Packets/s, Flows/s, Unique IPs
- Geo-IP mapping: Traffic theo quốc gia, heatmap
- Protocol distribution: Pie chart, trend
- Conversation matrix: Ai nói với ai (Sankey diagram)
- Anomaly: Machine learning baseline → Outlier detection (Isolation Forest, LSTM, ARIMA...)
- Threat Intel enrichment: IP reputation, GeoIP, ASN, Domain reputation