· 7 min read

MikroTik Traffic Flow Export to a DDoS Collector (RouterOS v7)

MikroTik Traffic Flow export on RouterOS v7 is configured with /ip traffic-flow plus a target that points to your DDoS detection collector. To make it useful for attack detection, you need short flow timeouts, the right interfaces, and a clear check that flows actually arrive.

This guide covers a working RouterOS v7 configuration, how to think about sampling, how to verify each hop, and the mistakes that most often leave a collector blind during an attack. Example addresses use documentation ranges: the router is 198.51.100.1 and the collector is 192.0.2.10.

What a DDoS collector needs from the router

Detection is only as good as the flow data. For volumetric and packet-rate attacks the collector needs:

For background on thresholds and baselines, see our earlier article on NetFlow DDoS detection. Here we stay on the MikroTik side.

Step 1: Pick the protocol version

RouterOS v7 supports several export versions in the target definition:

Version Use it when
5 IPv4 only, simplest collectors
9 NetFlow v9, template-based, supports IPv6
10 IPFIX, standardized and template-based

If you carry IPv6 (and you probably do), use 9 or 10. v5 has no IPv6 fields. Check that your collector supports the version you choose. NixMon accepts NetFlow v5/v9, IPFIX and sFlow, so either works there.

Step 2: Enable Traffic Flow on RouterOS v7

/ip traffic-flow
set enabled=yes \
    interfaces=ether1-transit,ether2-ix \
    cache-entries=128k \
    active-flow-timeout=30s \
    inactive-flow-timeout=10s

/ip traffic-flow target
add dst-address=192.0.2.10 port=2055 \
    src-address=198.51.100.1 \
    version=9

For IPFIX, change version=9 to version=10.

What the key settings do:

The v9 template refresh settings (v9-template-refresh, v9-template-timeout) are also available on the target. If your collector starts after the router, a shorter refresh interval means it learns templates sooner. Run /ip traffic-flow target print detail to see the exact options on your RouterOS build.

Step 3: Think about sampling

By default, MikroTik Traffic Flow is not a sampled export: the router tracks connections in its flow cache and exports records for them. That gives accurate counters, but it costs CPU and memory on small routers, especially under floods with many unique sources.

Recent RouterOS v7 releases also expose packet sampling options under /ip traffic-flow (packet-sampling, sampling-interval, sampling-space). Availability and exact semantics depend on the version, so check /ip traffic-flow print and the MikroTik documentation for your release before relying on them.

Practical guidance:

For a deeper discussion of rates and trade-offs, see our article on sFlow vs NetFlow vs IPFIX.

Step 4: Allow the export through your firewall

If you filter traffic leaving the router, allow UDP to the collector. A minimal example:

/ip firewall filter
add chain=output action=accept protocol=udp \
    dst-address=192.0.2.10 dst-port=2055 \
    comment="traffic-flow export"

Place it above any rule that would drop it. Also confirm the collector host (or the network in front of it) accepts inbound UDP/2055:

# Linux collector, nftables example
nft add rule inet filter input ip saddr 198.51.100.1 udp dport 2055 accept

Step 5: Verify, hop by hop

Troubleshoot in order. Most "no data" problems are found in the first two checks.

1. On the router: is Traffic Flow active?

/ip traffic-flow print
/ip traffic-flow target print

Confirm enabled=yes, the right interfaces and the right collector address and port.

2. On the router: are packets leaving?

/tool sniffer quick ip-address=192.0.2.10 port=2055

You should see UDP packets to the collector every few seconds when there is traffic on the monitored interfaces. If you see none, check that the monitored interfaces carry routed traffic and that the flow isn't bypassing the router's flow accounting (see mistakes).

3. On the collector: are packets arriving?

tcpdump -ni eth0 'udp port 2055 and host 198.51.100.1'

If the router sends and the collector doesn't receive, look at upstream ACLs, host firewall rules and asymmetric paths to the management network.

4. On the collector: are records decoded?

An independent decoder is a good sanity check. With nfdump:

nfcapd -w -D -p 2055 -l /var/cache/nfdump
nfdump -R /var/cache/nfdump -s dstip/bytes -n 10

This shows the top destination IPs by bytes. Compare with a known value, such as a test download to a host in 203.0.113.0/24, or with interface counters (/interface monitor-traffic ether1-transit). Large unexplained differences point to a sampling, direction or double-counting problem. Stop nfcapd before pointing the real collector at the same port, since two listeners can't share it.

5. In the detection platform: do thresholds work end to end?

Generate a controlled burst toward a test IP, for example with iperf3 UDP or hping3 from a lab host you own, and confirm the per-IP bps/pps counters rise and an alert fires. Test with a low temporary threshold rather than a real attack.

Common mistakes

From flows to action

Once flows are arriving, the collector can compare per-IP and per-prefix rates against thresholds and trigger a response. NixMon traffic monitoring and DDoS detection ingests NetFlow v5/v9, IPFIX and sFlow, analyzes traffic with sub-second analytics, and can announce BGP blackhole (RTBH) or BGP FlowSpec routes, or trigger the on-prem NixGuard firewall. Networks with their own ASN and at least one /24 can also use NixGuard Edge, where clean traffic returns over a GRE tunnel with a BGP session inside.

You can test the full path from MikroTik to alert with the 15-day free trial, which doesn't require a credit card.

Frequently asked questions

Should I use NetFlow v9 or IPFIX on MikroTik RouterOS v7?

Both are template-based and support IPv6. Use whichever your collector handles best. IPFIX is version=10 in the RouterOS target; NetFlow v9 is version=9. Use v5 only if you have IPv4 traffic only and a collector that needs it.

What active flow timeout should I use for DDoS detection?

The 30-minute default is too long. Start around 30 seconds or lower and watch router CPU and export volume. Pair it with an inactive timeout of roughly 10-15 seconds.

Why does my collector show no MikroTik flows?

Check in order: Traffic Flow is enabled on the right interfaces, the target IP and port are correct, the router actually sends UDP (use /tool sniffer quick), a firewall isn't blocking UDP to the collector, and the collector decodes the version and templates you export.

Do I need to configure the sampling rate on the collector?

If you enable packet sampling on the router, yes in most cases. Unless the collector learns the rate from the export or you set it manually, counters will be understated and per-IP bps/pps thresholds won't fire as expected.

Test MikroTik flow detection free for 15 days, no credit card.Learn more