Monitoring and Troubleshooting · Topic 3 of 3
Monitoring the Packet Flow Process
Learn to monitor SRX packet flow for JNCIA-SEC: first path and fast path stages, flow traceoptions, packet filters, basic-datapath and reading traces.
- 6 min
- IPv4 is flow based by default; the first packet builds a session, later packets use the fast path.
- First path order: screens, static and destination NAT, route, zone, policy, reverse static and source NAT, services, session creation.
- Fast path: screens, TCP checks, NAT from the session, services, forwarding.
What it is
Monitoring the packet flow process means watching each stage the SRX applies to a packet, so you can see exactly where and why it is dropped. The tool for this is flow traceoptions: a debug trace of the flow module, written to a log file and limited by packet filters to the traffic you care about.
Use it when the session table, policy checks and counters do not explain the problem. The trace shows each stage and the final decision for every traced packet.
How it works
The stages a packet passes
The SRX processes IPv4 in flow mode by default. The first packet of a flow takes the first path, which builds a session. Later packets that match the session take the fast path.
| First path (new session) | Fast path (existing session) |
|---|---|
| Screens | Screens |
| Static NAT and destination NAT | TCP checks |
| Route lookup | NAT, using the stored translation |
| Zone lookup | Services such as ALGs |
| Policy lookup | Forward to the egress interface |
| Reverse static NAT and source NAT | |
| Services such as ALGs | |
| Session created |
Stateless firewall filters, policers and class of service act before and after this flow processing, on the ingress and egress interfaces. A packet dropped by a firewall filter never reaches the flow module.
A packet can be dropped on either path; on the fast path, for example, by a screen or a TCP check.
Configuring flow traceoptions
Flow traceoptions are configured under [edit security flow traceoptions]. You need a file, a flag, and a packet filter.
user@srx# set security flow traceoptions file flow-trace
user@srx# set security flow traceoptions file size 1m
user@srx# set security flow traceoptions file files 3
user@srx# set security flow traceoptions flag basic-datapath
user@srx# set security flow traceoptions packet-filter PF-WEB source-prefix 10.1.1.10/32
user@srx# set security flow traceoptions packet-filter PF-WEB destination-prefix 198.51.100.20/32
user@srx# commit
| Part | Purpose |
|---|---|
file flow-trace | The trace file name, created under /var/log/ |
size, files | Maximum size of each file and how many rotated files to keep |
flag basic-datapath | Traces the basic packet path decisions: session, NAT, route, zone, policy |
packet-filter | Limits tracing to matching packets |
Packet filters
A packet filter can match on several fields.
| Option | Matches |
|---|---|
source-prefix | Source address or subnet |
destination-prefix | Destination address or subnet |
source-port, destination-port | Port numbers |
protocol | IP protocol |
interface | Ingress logical interface |
All options inside one packet filter must match. Several packet filters can be configured, and a packet that matches any of them is traced. Add a second filter for the reply direction if you need to see return packets after NAT.
Flow tracing without a packet filter traces every packet through the device. On a busy SRX that fills the file at once and adds load. Always filter tightly, and remove the trace when you are done.
Reading the trace
user@srx> show log flow-trace
user@srx> show log flow-trace | match drop
user@srx> clear log flow-trace
Each packet in the trace appears as a series of lines, one per stage. Read them in order and look for:
- whether an existing session was found, or a new one is being built
- the result of any NAT lookup, with the translated address
- the route lookup and the zones it found
- the policy search and the policy that matched, or the default deny
- a line saying the packet was dropped, and the reason
If the trace shows the to-zone you did not expect, the problem is routing. If it shows a deny with the right zones, the problem is the policy. If the packet never appears in the trace, it was dropped before the flow module, for example by a firewall filter, or it never reached the SRX.
Removing the trace
Traces are for short-term use. Turn them off with deactivate to keep the configuration for later, or delete to remove it.
user@srx# deactivate security flow traceoptions
user@srx# commit
Other flow monitoring commands
| Command (operational mode) | Shows |
|---|---|
show security flow status | Flow forwarding mode for each family |
show security flow session summary | Session counts |
show security screen statistics zone untrust | Packets dropped by each screen |
show interfaces ge-0/0/0 extensive | Interface errors and drops below the flow module |
A packet that does not show up in a filtered trace at all is useful evidence. It means the problem is before the flow module: the cable, the interface, a firewall filter or the upstream device.
Common mistakes
Tracing without a packet filter. It floods the trace file and loads the device.
Leaving traceoptions running. Deactivate or delete them after troubleshooting.
Expecting a trace of only one direction to show replies. After source NAT, the reply has different addresses; add a packet filter for the return direction.
Expecting fast path packets to show a policy lookup. Only the first packet runs the policy search; later packets use the session.
Using monitor traffic for transit flow. It shows host traffic only; flow traceoptions show transit packet processing.
What to remember for the exam
- IPv4 is flow based by default; the first packet builds a session, later packets use the fast path.
- First path order: screens, static and destination NAT, route, zone, policy, reverse static and source NAT, services, session creation.
- Fast path: screens, TCP checks, NAT from the session, services, forwarding.
- Flow traceoptions live under
security flow traceoptionswithfile,flag basic-datapathandpacket-filter. - Options in one packet filter are combined with AND; separate packet filters are combined with OR.
- Trace files are under
/var/log/; read them withshow log <file>. - Deactivate or delete traceoptions when finished.
Check yourself
Which flag traces the basic session, NAT, route and policy decisions in the flow module?
flag basic-datapathundersecurity flow traceoptions.A packet filter has a source-prefix and a destination-prefix. Which packets are traced?
Only packets that match both, because options inside one packet filter must all match.
A filtered trace shows no lines at all for a host's traffic. What does that suggest?
The packets never reached the flow module, so look for a firewall filter, an interface problem or an upstream issue.
Topic 3 of 3 in Monitoring and Troubleshooting
Test yourself on Monitoring and Troubleshooting
The full Juniper JNCIA-SEC JN0-232 question bank has 658 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.