Why IPFIX with inline J-Flow
On Juniper MX routers with MPC (Trio) line cards, inline J-Flow samples packets and builds flows right on the Packet Forwarding Engine, with no services card. Export goes out as IPFIX or NetFlow v9, carrying IPv6, source and destination ASN, and the input and output interface indexes. Those are the fields EdgeWarden uses to pinpoint the target under attack, the protocol, and the interface the attack comes in on.
You'll configure IPv4 and IPv6 IPFIX templates, the sampling instance that exports to 192.0.2.10:2055, the FPC, the edge interfaces, and SNMP, then verify everything on the router and in EdgeWarden.
Prerequisites
- Juniper MX with the Trio chipset running Junos OS. Anything that changes between releases is called out in the text.
- Next Gen Services disabled: with it enabled, the MX doesn't do inline J-Flow.
- A stable source address for export, ideally the loopback (
198.51.100.1in the examples), with a route to the collector over the data plane. The MX doesn't export inline flows through thefxp0management interface. - Port 2055/UDP open on the EdgeWarden server.
- A free license slot: each source IP counts as one exporter (Starter 1, Professional 2, Enterprise 10); above the quota, flows are dropped with no warning on screen.
Step 1: IPFIX templates
Create one template per address family. Timeouts accept 10 to 600 seconds (default 60).
set services flow-monitoring version-ipfix template ew-ipv4 ipv4-template
set services flow-monitoring version-ipfix template ew-ipv4 flow-active-timeout 60
set services flow-monitoring version-ipfix template ew-ipv4 flow-inactive-timeout 15
set services flow-monitoring version-ipfix template ew-ipv4 template-refresh-rate seconds 60
set services flow-monitoring version-ipfix template ew-ipv4 option-refresh-rate seconds 60
set services flow-monitoring version-ipfix template ew-ipv6 ipv6-template
set services flow-monitoring version-ipfix template ew-ipv6 flow-active-timeout 60
set services flow-monitoring version-ipfix template ew-ipv6 flow-inactive-timeout 15
set services flow-monitoring version-ipfix template ew-ipv6 template-refresh-rate seconds 60
set services flow-monitoring version-ipfix template ew-ipv6 option-refresh-rate seconds 60The active timeout sets how often a long-lived flow, such as an attack, gets exported, and it adds to EdgeWarden's analysis cycle (10 s by default). 60 s is the usual recommendation; lower values detect sooner and generate more export traffic. The default template refresh is 600 s: after a collector restart, data can't be decoded until the template arrives again. At 60 s, that wait drops to one minute.
Step 2: sampling instance
set forwarding-options sampling instance ew-sampling input rate 1000
set forwarding-options sampling instance ew-sampling family inet output flow-server 192.0.2.10 port 2055
set forwarding-options sampling instance ew-sampling family inet output flow-server 192.0.2.10 version-ipfix template ew-ipv4
set forwarding-options sampling instance ew-sampling family inet output inline-jflow source-address 198.51.100.1
set forwarding-options sampling instance ew-sampling family inet output inline-jflow flow-export-rate 10
set forwarding-options sampling instance ew-sampling family inet6 output flow-server 192.0.2.10 port 2055
set forwarding-options sampling instance ew-sampling family inet6 output flow-server 192.0.2.10 version-ipfix template ew-ipv6
set forwarding-options sampling instance ew-sampling family inet6 output inline-jflow source-address 198.51.100.1
set forwarding-options sampling instance ew-sampling family inet6 output inline-jflow flow-export-rate 10input rate 1000samples 1 out of every 1,000 packets. Write this value down: it goes into the device record.- Use the same
source-addressfor both families. EdgeWarden identifies the exporter by source IP, so the MX takes a single license slot and a single device record. - The collector and source stay IPv4 under family
inet6too: IPv6 flows travel inside IPv4 packets. Juniper only documents IPv6 addresses inflow-serverandsource-addressstarting in Junos OS Evolved 23.1R1, on PTX routers. flow-export-rateis in thousands of packets per second and applies to the whole FPC (default 1, too low for an edge under attack). The ceiling depends on the chip: 100 per PFE with an LU chip (200 on an MPC2, which has two) and 800 per XL/EA PFE. A value above what the card supports passes commit but may log an error in Junos.
Prefer NetFlow v9? Replace version-ipfix with version9 in the templates and on the flow-server lines. With inline J-Flow, v9 for IPv6 is only available starting in Junos 18.1R1.
Step 3: bind the instance to the FPC
Without this, the instance stays inactive. Each FPC takes one instance; repeat for every FPC with sampled interfaces.
set chassis fpc 0 sampling-instance ew-sampling
set chassis fpc 0 inline-services flow-table-size ipv4-flow-table-size 8
set chassis fpc 0 inline-services flow-table-size ipv6-flow-table-size 4On the MX5, MX10, MX40, and MX80 use set chassis tfeb slot 0 sampling-instance ew-sampling; on the MX104, set chassis afeb slot 0 sampling-instance ew-sampling.
Each flow-table-size unit is 256K entries. Since Junos 16.1R1 and 15.1F2 the IPv4 and IPv6 tables default to only 1,024 entries each, not much for an edge under attack with spoofed sources. The per-table maximum depends on the line card (Junos 17.3R1 or later): 15 units on the MPC2E, MPC3E, and MPC4E, 48 on the MPC7E, and 220 on the MPC5E and MPC6E.
Before Junos 16.1R1 and 15.1F2, changing flow-table-size reboots the FPC. On those releases, make the change in a maintenance window.
Step 4: sampling on the interfaces
Sample ingress on your transit and IX interfaces, where attacks come in. To see attacks leaving from customers, also sample ingress on the customer-facing interfaces.
set interfaces xe-0/0/0 unit 0 family inet sampling input
set interfaces xe-0/0/0 unit 0 family inet6 sampling input
set interfaces xe-0/0/1 unit 0 family inet sampling input
set interfaces xe-0/0/1 unit 0 family inet6 sampling input
commit check
commit confirmed 10
commitIf the interface already has an input filter, the alternative is a term with then sample and then accept in that filter.
Step 5: SNMP for interface names
Flows carry the ifIndex; the interface name and capacity come from SNMP. Without SNMP, the interface disappears from the Interfaces screen.
set snmp community ew-readonly authorization read-only
set snmp community ew-readonly clients 192.0.2.10/32Use a long community string or SNMPv3, and allow UDP 161 from 192.0.2.10 if you have a filter on lo0. Sampling is configured on the unit, and the ifIndex carried in the flow is the logical interface's (xe-0/0/0.0), not the physical port's. To match an ifIndex to an interface:
show interfaces xe-0/0/0 | match "SNMP ifIndex"
Interface index: 148, SNMP ifIndex: 526
Logical interface xe-0/0/0.0 (Index 333) (SNMP ifIndex 527)Verification on the router
According to Juniper, flows are only created after the route record resync completes, about 120 s after the commit.
show services accounting status inline-jflow fpc-slot 0
FPC Slot: 0
IPV4 export format: Version-IPFIX, IPV6 export format: Version-IPFIX
Route-Records Set: Yes, Config Set: Yes
Service Status: PFE-0: Steady
show services accounting flow inline-jflow fpc-slot 0
Flow information
FPC Slot: 0
Flow Packets: 1843220, Flow Bytes: 1503127744
Active Flows: 20915, Total Flows: 611043
Flows Exported: 590128, Flow Packets Exported: 21870
Flows Inactive Timed Out: 561200, Flows Active Timed Out: 28928
show services accounting errors inline-jflow fpc-slot 0
Error information
FPC Slot: 0
Flow Creation Failures: 0
Route Record Lookup Failures: 0, AS Lookup Failures: 0
Export Packet Failures: 0
Memory Overload: No, Memory Alloc Fail Count: 0Config Set: Yes and Route-Records Set: Yes show that the instance reached the FPC. On newer releases, the same output includes IPv4 MAX FLOW Count and IPv6 MAX FLOW Count: compare them before and after step 3 to confirm the new table size took effect. Flows Exported should increase on every run. Rising Flow Creation Failures or Memory Overload: Yes point to an undersized flow table.
Verification in EdgeWarden
- Under Configurações → Rede → Dispositivos (Settings → Network → Devices), add the MX with Endereço IP (IP address)
198.51.100.1(thesource-address), Taxa de Amostragem de Flow (flow sampling rate)1000, and the SNMP settings. - In the list, the SNMP column should show Online and the Tráfego atual (current traffic) column should show a value instead of a dash.
- The Amostragem (sampling) column shows detectado (detected) when the router announces its rate via Options Template, and that value overrides the device record; manual when the record applies. If you see
cadastro: 1:N (ignorado), update the record to the announced value. - Within 1 to 2 minutes of the router starting to export, flows show up on the Flows screen. Filter by Exporter IP
198.51.100.1. Values are already multiplied by the sampling rate. - Validate the rate in the Fluxo × SNMP nas interfaces (flow vs. SNMP on interfaces) panel of the Análise do instante (instant analysis) screen (menu Tráfego → Análise do instante, or click a point on a traffic chart): 1/N of SNMP means the rate is missing; N× means it was applied twice.
If nothing arrives, run tcpdump -i any -n udp port 2055 and host 198.51.100.1 on the server and follow journalctl -u flowspec-core -f.
Common pitfalls
- Source differs from the device record: interfaces show up as
if:527and per-interface traffic disappears. - Instance not bound to an FPC: interfaces on an FPC without
sampling-instancedon't generate flows. - sFlow and inline J-Flow on the same interface: unpredictable behavior, according to Juniper.
- LAG on egress: with ingress sampling, if the egress interface is an
ae, the MX reports the output interface as invalid. - Fixed fields: the MX template includes TCP flags (IE 6) and minimum and maximum TTL (IE 52/53), but not
fragmentOffset/fragmentFlags(IE 88/197), and none of the MX IPFIX templates Juniper documents include them. ThefragmentIdentification(IE 54) it does export doesn't tell whether a packet is a fragment. The Fragment Flood detector is blind to MX traffic; if only MX routers export to EdgeWarden, the log warns that the detector is inert. - ECMP: when the destination has multiple paths, the MX reports the first path for IPv4 and zeroes out the output interface and next hop for IPv6. The fix is next-hop learning (Junos 15.1F2 or later), shown below.
set services flow-monitoring version-ipfix template ew-ipv4 nexthop-learning enable
set services flow-monitoring version-ipfix template ew-ipv6 nexthop-learning enableAnyone who can reach 2055/UDP can inject forged flows and poison detection. Restrict the port to your routers' IPs.
Next steps
Still choosing between IPFIX, NetFlow v9, and sFlow? See NetFlow v5, v9, IPFIX, or sFlow: which one to export. If any step fails, work through the checklist No flows showing up in EdgeWarden?. Review ports and buffers in the installation guide, and see in Features how EdgeWarden uses these flows to detect attacks.