How to export NetFlow v9 and IPFIX from MikroTik RouterOS v7 to EdgeWarden

RouterOS v7 Traffic Flow step by step: timeouts for fast detection, IPFIX target, fields, sampling, SNMP, and the FastTrack and hardware offload pitfalls.

What you'll configure

Traffic Flow is the RouterOS NetFlow and IPFIX exporter. In this guide you'll enable it on a MikroTik edge router running RouterOS v7, point the export at the EdgeWarden collector at 192.0.2.10, port 2055/UDP, and tune the handful of settings that decide whether an attack shows up in seconds or in half an hour.

The setting that matters most for DDoS detection is active-flow-timeout. The RouterOS default is 30 minutes: a long-lived flow, such as a sustained UDP flood against a customer, would only be reported to the collector after that. At 1 minute, EdgeWarden receives the flow and analyzes it on the next cycle, which runs every 10 seconds by default.

Prerequisites

  • RouterOS v7. The commands follow MikroTik's official RouterOS v7 documentation.
  • EdgeWarden installed per the installation guide, with 2055/UDP open to the router's IP.
  • A fixed source address for the export, ideally a loopback. In this example: 198.51.100.1.
  • Free exporter quota on the license (Starter 1, Professional 2, Enterprise 10). An exporter over the quota is dropped before parsing, with no error on screen.

This guide doesn't cover RouterOS v6. Very old guides use address=192.0.2.10:2055 on the target; current versions use dst-address and port, as in the commands below. The current documentation also states that packet sampling is a v7 feature. On v6, check each parameter with ? in the console before applying it.

Step 1: enable Traffic Flow and tune the timeouts

The default interfaces=all makes the router account for everything the CPU handles, including internal traffic that is irrelevant to detection. List only your transit, IX and CDN links, comma-separated:

RouterOS v7: enable Traffic Flow
/ip traffic-flow set enabled=yes interfaces=sfp-sfpplus1,ether1 cache-entries=256k active-flow-timeout=1m inactive-flow-timeout=15s
ParameterDefaultSuggestedWhy
active-flow-timeout30m1mLong-lived flows are exported every minute. Lower means faster detection and more load
inactive-flow-timeout15s15sThe documentation warns that very low values create too many flows and can overflow the buffer
cache-entries4ksized to RAM4k is too small for an ISP edge; a spoofed-source attack creates thousands of flows per second
interfacesalledge linksFewer interfaces, less CPU

Total detection latency with NetFlow or IPFIX is the router's active timeout plus the EdgeWarden analysis cycle. If you need sub-second reaction, use sFlow or the Packet Sensor.

Step 2: create the target

src-address pins the source IP of the export packets, and that is the IP you'll register in EdgeWarden.

RouterOS v7: IPFIX target
# IPFIX to the collector, sourced from the loopback
/ip traffic-flow target add dst-address=192.0.2.10 port=2055 version=ipfix src-address=198.51.100.1

For NetFlow v9, change it to version=9. Use a single target per collector: two targets to the same destination double the volume. The template is resent every 20 packets (v9-template-refresh, default); on low-traffic routers, also set v9-template-timeout so the collector isn't left waiting for the template after a reboot.

Step 3: pick the IPFIX fields

The /ip traffic-flow ipfix menu turns each record field on or off. Check the current state and make sure the fields the detectors rely on are enabled:

RouterOS v7: IPFIX record fields
/ip traffic-flow ipfix print
/ip traffic-flow ipfix set src-address=yes dst-address=yes src-port=yes dst-port=yes protocol=yes bytes=yes packets=yes tcp-flags=yes ttl=yes tos=yes icmp-type=yes icmp-code=yes in-interface=yes out-interface=yes src-address-mask=yes dst-address-mask=yes gateway=yes first-forwarded=yes last-forwarded=yes

Without tcp-flags, the SYN, ACK and RST detectors go blind; without in-interface and out-interface, per-interface traffic disappears. Fields such as tcp-seq-num, tcp-ack-num, tcp-window-size and the MAC addresses aren't used for detection and can be turned off to shrink the records.

EdgeWarden notices when the exporter doesn't send a field and logs which detector goes inert. The RouterOS field list has no fragmentation fields, so expect that warning for the Fragment Flood detector. If the log also flags TTL Variance, the exported TTL isn't reaching the field that detector reads (minimumTTL, IE 52); the other detectors keep working.

Step 4 (optional): sampling

sampling-interval is the number of packets sampled in a row and sampling-space is the number of packets skipped after that. For 1 in 1000:

RouterOS v7: 1:1000 sampling
# 1 packet sampled, 999 skipped
/ip traffic-flow set packet-sampling=yes sampling-interval=1 sampling-space=999

The effective rate is (interval + space) / interval. Stick with sampling-interval=1: with larger values RouterOS samples bursts of consecutive packets rather than evenly spaced ones.

EdgeWarden multiplies bytes and packets by the rate before storing them. It uses the rate advertised in an Options Template when the router sends one; the RouterOS documentation doesn't describe that advertisement, so set Taxa de Amostragem de Flow (flow sampling rate) to 1000 on the device record and check the manual or detectado badge on screen. If the router does advertise the rate, the advertised value wins and the screen flags cadastro: 1:N (ignorado) when it differs from the record. Without sampling, leave it at 1.

Step 5: SNMP for interface names

The flow carries the interface index; the name and capacity come from SNMP. Allow read access for the collector only:

RouterOS v7: read-only SNMP
/snmp community add name=edgewarden-ro addresses=192.0.2.10/32 read-access=yes write-access=no
/snmp set enabled=yes src-address=198.51.100.1
/interface print oid

In the print oid output, the last number of each OID is the interface ifIndex. For SNMPv3, the community accepts security=private with authentication and encryption, and EdgeWarden supports v3 on the device record. Also review the default public community, which MikroTik itself calls insecure: restrict its addresses or disable it.

Verification on the router

RouterOS v7: check the export
/ip traffic-flow print
/ip traffic-flow target print
/tool sniffer quick ip-address=192.0.2.10 port=2055

The two print commands should show enabled: yes, the interfaces and timeouts you chose, and the target with 192.0.2.10, port 2055. sniffer quick shows packets leaving for the collector; stop it with Ctrl+C.

Verification on EdgeWarden

On the server, first confirm the packets arrive from the right IP:

EdgeWarden server: packets from the MikroTik
sudo tcpdump -i any -n -c 5 udp port 2055 and host 198.51.100.1
10:15:02.481233 ens18 In  IP 198.51.100.1.40312 > 192.0.2.10.2055: UDP, length 1372
sudo journalctl -u flowspec-core -f

Then, in the web UI:

  1. Under Configurações → Rede → Dispositivos (Settings → Network → Devices), add the router with Endereço IP (IP address) 198.51.100.1 (the same src-address as the target), the SNMP community and the sampling rate.
  2. Within 1 to 2 minutes, flows show up on the Flows screen. Under Tráfego → Interfaces (Traffic → Interfaces), names should read sfp-sfpplus1, not if:12.
  3. Compare the volume of a busy interface with its SNMP counter in the Fluxo × SNMP nas interfaces panel on the Análise do instante screen. If flow shows 1/N of SNMP, the rate is missing; if it shows N times, it was applied twice.

Anyone who can reach 2055/UDP can inject forged flows. Restrict by source: sudo ufw allow from 198.51.100.1 to any port 2055 proto udp.

Common pitfalls

Per MikroTik's documentation, FastTrack packets bypass ip traffic-flow, and Traffic Flow only sees what goes through the CPU: hardware-offloaded traffic (L3HW routing on the switch chip, offloaded bridging) never becomes a flow.

  • FastTrack enabled on the edge. The default configuration on many devices has an action=fasttrack-connection rule in the forward chain. Only a fraction of the packets in those connections takes the normal path; volume ends up far below SNMP and the legitimate-traffic baseline gets skewed. Find the rule with /ip firewall filter print where action=fasttrack-connection and decide whether it belongs on an edge router.
  • L3HW on CRS3xx, CRS5xx, CCR2116 and CCR2216. With l3-hw-offloading on, the switch chip routes without the CPU and, according to MikroTik, that traffic isn't reported through Traffic Flow. If volume doesn't match SNMP, check this before touching the rate.
  • Mirrored port. Mirroring traffic from a switch to the MikroTik doesn't work: mirrored packets are dropped before the input chain.
  • CPU load. Traffic Flow processes every packet on the CPU. Watch it with /tool profile cpu=total at peak; if the CPU gets tight, cut down the interfaces or use sampling.
  • Source IP doesn't match the device record. Without src-address, the export leaves with the egress interface IP. EdgeWarden can't match the flows to the device and interfaces stay unnamed.
  • Default 30-minute timeout. The most common cause of "the attack only showed up after it was over."

Next steps

If flows still don't show up after these steps, follow the flows not showing up troubleshooting guide, from packet capture on the server to the license quota. To choose the sampling rate and timeouts more carefully, read sampling and timeouts without missing attacks. To review collector ports and services, go back to the installation guide, and see in Features how EdgeWarden uses these flows to detect and mitigate attacks.

Related articles

All articles

Want to see these flows in EdgeWarden?

Create your account in the Customer area and generate the demo license: 7 days with every Enterprise feature, on your own server. Then follow the installation guide to bring up the collector.