Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

NetFlow là gì? Vai trò trong an ninh mạng, phân tích lưu lượng, phát hiện bất thường

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

  1. Thiết bị NetFlow-enabled (router/switch/firewall) nhận gói tin
  2. Kiểm tra flow cache: Nếu khớp 5-tuple → cập nhật counter (packets, bytes, timestamp)
  3. Nếu không khớp → tạo flow record mới
  4. Flow hết hiệu lực (timeout active/inactive) hoặc TCP FIN/RST → Export flow record đến NetFlow Collector
  5. 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

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

Lợi íchMô 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 ResponseTruy 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 HuntingTruy 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 VisibilityTop talkers, top protocols, ứng dụng tiêu tốn băng thông, shadow IT, rogue device
Capacity PlanningXu hướng băng thông, upgrade link, QoS, cost optimization
Compliance & AuditingChứng minh segmentation hoạt động, không traffic trái phép giữa zone, log retention
Chi phí thấp hơn PCAPLưu trữ 1-5% dung lượng so với full packet capture, giữ được 30-90+ ngày

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)

  1. Exporter: Router/Switch/Firewall sinh flow record → Export UDP (port 2055, 9995, 4739...)
  2. Collector: Nhận, lưu trữ, pre-process flow data (nProbe, ntopng, Splunk, Elastic, Kafka...)
  3. 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
Tiêu chíNetFlowFull 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àyHours-đ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/C2Tốt cho behavioral, metadataTốt cho signature, payload analysis
Latency phân tíchReal-time/near real-timeChậm (cần index, decode)