Flow monitoring — NetFlow, IPFIX, sFlow
export-protocol ipfix in the flow exporter.| NetFlow v9 / IPFIX | sFlow | |
|---|---|---|
| How it works | The device keeps a flow cache and exports one record per flow | The switch samples 1 in N packets in hardware and sends their headers |
| Accuracy | Exact bytes and packets per conversation (unsampled) | Statistical estimate; small or short conversations may not appear at all |
| Load on the device | CPU and memory for the flow cache, growing with the number of concurrent flows. Fine with hardware NetFlow, can be significant on software-based platforms | Low and constant, independent of the traffic volume |
| Export traffic to XorMon | Grows with the number of flows | Grows with packets / N, predictable |
| Typical devices | Cisco routers, Catalyst 9000, firewalls | High-speed data center / core switches (e.g. Nexus 3000/9000), most non-Cisco switches (Arista, Juniper, HPE Aruba, Dell) |
show flow monitor XORMON-MONITOR statistics); if the cache overflows or the CPU is high, use sampled NetFlow or fewer devices.! global ip flow-export version 9 ip flow-export destination <XORMON_IP> 2055 ip flow-cache timeout active 1 ip flow-cache timeout inactive 15 ! on every interface of the device (ingress only) interface GigabitEthernet0/1 ip route-cache flowOn later 12.4/15.x releases,
ip route-cache flow is replaced by:
interface GigabitEthernet0/1 ip flow ingressVerify with:
show ip flow export show ip cache flow
flow record XORMON-RECORD match ipv4 protocol match ipv4 source address match ipv4 destination address match transport source-port match transport destination-port match interface input collect interface output collect counter bytes long collect counter packets long collect timestamp sys-uptime first collect timestamp sys-uptime last flow exporter XORMON-EXPORTER destination <XORMON_IP> transport udp 2055 export-protocol netflow-v9 source Loopback0 flow monitor XORMON-MONITOR record XORMON-RECORD exporter XORMON-EXPORTER cache timeout active 60 cache timeout inactive 15 ! on every interface of the device (input only) interface GigabitEthernet1/0/1 ip flow monitor XORMON-MONITOR inputVerify with:
show flow monitor XORMON-MONITOR cache show flow exporter XORMON-EXPORTER statistics
flow exporter XORMON-EXPORTER destination <XORMON_IP> transport udp 2055 export-protocol ipfix source Loopback0XorMon receives NetFlow v9 and IPFIX on the same port and shows the same data for both, so either choice works. Classic NetFlow (
ip flow-export) cannot export IPFIX — use Flexible NetFlow for it.flow record XORMON-RECORD-V6 match ipv6 protocol match ipv6 source address match ipv6 destination address match transport source-port match transport destination-port match interface input collect interface output collect counter bytes long collect counter packets long collect timestamp sys-uptime first collect timestamp sys-uptime last flow monitor XORMON-MONITOR-V6 record XORMON-RECORD-V6 exporter XORMON-EXPORTER cache timeout active 60 cache timeout inactive 15 ! on every interface of the device (input only), next to the IPv4 monitor interface GigabitEthernet1/0/1 ip flow monitor XORMON-MONITOR input ipv6 flow monitor XORMON-MONITOR-V6 inputVerify with:
show flow monitor XORMON-MONITOR-V6 cache
ip flow-export destination <XORMON_IP> 2055(the existing
ip flow-export destination <old_collector_ip> <port> line stays untouched)
flow monitor can reference multiple exporters, so add a new exporter and attach it to the existing monitor (no need to touch interface config):
flow exporter XORMON-EXPORTER destination <XORMON_IP> transport udp 2055 export-protocol netflow-v9 source Loopback0 flow monitor <EXISTING-MONITOR> exporter XORMON-EXPORTERIf the platform only allows one exporter per monitor (some older 9300/9500 code trains restrict this), the alternative is a second flow monitor with the same
flow record and a second exporter, applied to the same interfaces in addition to the existing one (ip flow monitor <NEW-MONITOR> input).
tcpdump -ni any udp port 2055Make sure the firewall allows inbound UDP/2055 from the switch.
feature sflow sflow sampling-rate 4096 sflow max-sampled-size 128 sflow collector-ip <XORMON_IP> vrf default sflow collector-port 6343 sflow agent-ip <SWITCH_IP> sflow data-source interface ethernet 1/1Repeat
sflow data-source interface for every port. Verify with show sflow and show sflow statistics.
sflow sample 16384 sflow destination <XORMON_IP> 6343 sflow source-interface Loopback0 sflow runsFlow is then active on all Ethernet interfaces; exclude one with
no sflow enable in the interface configuration. Verify with show sflow.
set protocols sflow collector <XORMON_IP> udp-port 6343 set protocols sflow sample-rate ingress 2048 set protocols sflow agent-id <SWITCH_IP> set protocols sflow interfaces ge-0/0/0.0Repeat
interfaces for every port. Verify with show sflow and show sflow collector.
sflow collector <XORMON_IP> port 6343 sflow agent-ip <SWITCH_IP> sflow sampling 4096 sflowThe global
sflow command enables it on all interfaces. Verify with show sflow.
/etc/hsflowd.conf:
sflow {
sampling = 1000
collector { ip = <XORMON_IP> udpport = 6343 }
pcap { dev = eth0 }
}
Then systemctl restart hsflowd.
tcpdump -ni any udp port 6343Make sure the firewall allows inbound UDP/6343 from the switch.