
NetFlow และ sFlow: วิเคราะห์ Traffic Flow สำหรับ Network Visibility
NetFlow และ sFlow เป็น flow-based monitoring technologies ที่ให้ visibility ว่า traffic ใน network มาจากไหน ไปไหน ใช้ protocol อะไร ปริมาณเท่าไหร่ ต่างจาก SNMP ที่บอกแค่ bandwidth utilization ต่อ interface NetFlow/sFlow บอกรายละเอียดว่า traffic เป็นของ application อะไร user ไหน server ไหน
การมี traffic flow visibility ช่วยให้ตอบคำถามสำคัญได้: ใครใช้ bandwidth มากที่สุด? Application อะไรกิน bandwidth? มี traffic ผิดปกติหรือไม่? ควร upgrade link ไหน? มี unauthorized traffic หรือไม่? บทความนี้จะอธิบาย NetFlow และ sFlow พร้อมวิธี deploy ในองค์กร
NetFlow vs sFlow vs IPFIX
| คุณสมบัติ | NetFlow v5 | NetFlow v9/IPFIX | sFlow |
|---|---|---|---|
| Developer | Cisco | Cisco / IETF | InMon (multi-vendor) |
| Method | Flow-based (ทุก packet) | Flow-based (template) | Sampling-based (1 ใน N packets) |
| Accuracy | 100% (ทุก flow) | 100% (ทุก flow) | Statistical (sample rate dependent) |
| Performance Impact | สูง (CPU intensive) | สูง | ต่ำ (sampling = lightweight) |
| Vendor Support | Cisco only | Multi-vendor (IPFIX) | Multi-vendor (built-in บน most switches) |
| Layer 2 Info | ไม่มี | มี (v9 templates) | มี (full packet header) |
| Scalability | ปานกลาง | ดี | ดีมาก (low overhead) |
NetFlow Architecture
Components
| Component | บทบาท |
|---|---|
| Flow Exporter | Router/Switch ที่สร้าง flow records และส่งไป collector |
| Flow Collector | รับ flow records จาก exporters เก็บใน database |
| Flow Analyzer | วิเคราะห์และแสดงผลข้อมูล (dashboards, reports, alerts) |
Flow Record (7-tuple)
| Field | ตัวอย่าง |
|---|---|
| Source IP | 192.168.1.100 |
| Destination IP | 8.8.8.8 |
| Source Port | 54321 |
| Destination Port | 443 |
| Protocol | TCP (6) |
| Type of Service | 0 |
| Input Interface | Gi0/1 |
NetFlow Configuration (Cisco IOS)
NetFlow v9
Global Config: ip flow-export version 9 → ip flow-export destination 10.1.1.50 9996 → ip flow-export source Loopback0 → ip flow-cache timeout active 1 → ip flow-cache timeout inactive 15
Interface Config: interface GigabitEthernet0/0 → ip flow ingress → ip flow egress
sFlow Configuration
ตัวอย่าง (HP/Aruba Switch)
Config: sflow 1 destination 10.1.1.50 6343 → sflow 1 sampling 1/2048 → sflow 1 polling 30 interface config: interface 1 → sflow 1 sampling 2048
Sample Rate: 1/1024 สำหรับ 1G links 1/2048 สำหรับ 10G links 1/4096 สำหรับ 40G/100G links ยิ่ง sample rate สูง (ตัวเลขน้อย) ยิ่งแม่นยำ แต่ใช้ CPU/bandwidth มากขึ้น
Flow Collectors/Analyzers
| Tool | ประเภท | รองรับ | ราคา |
|---|---|---|---|
| ntopng | Open-source | NetFlow, sFlow, IPFIX | ฟรี (Community) |
| Elastiflow | Open-source | NetFlow, sFlow, IPFIX → Elasticsearch | ฟรี |
| PRTG | Commercial | NetFlow, sFlow, jFlow | $1,750+ |
| SolarWinds NTA | Commercial | NetFlow, sFlow, IPFIX, jFlow | $2,000+ |
| ManageEngine NetFlow Analyzer | Commercial | NetFlow, sFlow, IPFIX | $595+ |
| Plixer Scrutinizer | Commercial | NetFlow, sFlow, IPFIX | $$$ |
Use Cases
| Use Case | วิธีใช้ Flow Data |
|---|---|
| Bandwidth Monitoring | ดู top talkers, top applications, top destinations |
| Capacity Planning | วิเคราะห์ trend → วางแผน upgrade links ก่อนเต็ม |
| Security Monitoring | ตรวจจับ DDoS, port scans, data exfiltration, C2 beaconing |
| Troubleshooting | หาว่า traffic ผิดปกติมาจากไหน ไปไหน |
| QoS Validation | ยืนยันว่า QoS policy ทำงานถูกต้อง |
| Billing/Chargeback | คิดค่า bandwidth ตาม department/tenant |
Best Practices
| Practice | รายละเอียด |
|---|---|
| Enable บน key interfaces | WAN links, server uplinks, inter-VLAN (ไม่ต้องทุก port) |
| ใช้ sFlow สำหรับ high-speed | 10G+ links ใช้ sFlow (sampling) เพราะ overhead ต่ำกว่า |
| กำหนด retention policy | เก็บ raw flows 7-30 วัน, aggregated data 1-2 ปี |
| ตั้ง alerts | Alert เมื่อ traffic spike, new protocols, unusual destinations |
| Separate management traffic | ส่ง flow data ผ่าน management network |
ทิ้งท้าย: Flow Data = Network Intelligence
NetFlow/sFlow ให้ visibility ที่ SNMP ให้ไม่ได้ รู้ว่า traffic มาจากไหน ไปไหน application อะไร ใช้ sFlow สำหรับ high-speed + multi-vendor ใช้ NetFlow/IPFIX สำหรับ Cisco-centric environments ntopng หรือ Elastiflow เป็น open-source ที่ดี
อ่านเพิ่มเติมเกี่ยวกับ Zabbix Monitoring และ Wireshark Packet Analysis ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com