Configuring Packet Capture with a Configuration Editor
To configure packet capture on a device, you must perform the following tasks marked (Required):
- Enabling Packet Capture (Required)
- Configuring Packet Capture on an Interface (Required)
- Configuring a Firewall Filter for Packet Capture (Optional)
- Disabling Packet Capture
- Deleting Packet Capture Files
Enabling Packet Capture (Required)
To enable packet capture on the device:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 174.
- Go on to Configuring Packet Capture on an Interface (Required).
Table 174: Enabling Packet Capture
Task | J-Web Configuration Editor | CLI Configuration Editor |
|---|---|---|
Navigate to the Forwarding options level in the configuration hierarchy. |
In the configuration editor hierarchy, select Forwarding options. | From the [edit] hierarchy level, enter edit forwarding-options |
Specify in bytes the maximum size of each packet to capture in each file—for example, 500. The range is between 68 and 1500, and the default is 68 bytes. |
| Enter set packet-capture maximum-capture-size 500 |
Specify the target filename for the packet capture file—for example, pcap-file. For each physical interface, the interface name is automatically suffixed to the filename—for example, pcap-file.fe-0.0.1. (See the interface naming conventions in the Junos OS Interfaces Configuration Guide for Security Devices.) | In the Filename box, type pcap-file. | Enter set packet-capture file filename pcap-file |
Specify the maximum number of files to capture—for example, 100. The range is between 2 and 10,000, and the default is 10 files. | In the Files box, type 100. | Enter set packet-capture file files 100 |
Specify the maximum size of each file in bytes—for example, 1024. The range is between 1,024 and 104,857,600, and the default is 512,000 bytes. | In the Size box, type 1024. | Enter set packet-capture file size 1024 |
Specify if all users have permission to read the packet capture files. |
| Enter set packet-capture file world-readable |
Configuring Packet Capture on an Interface (Required)
To capture all transit and host-bound packets on an interface and specify the direction of the traffic to capture—inbound, outbound, or both:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 175.
- If you are finished configuring the device, commit the configuration.
- Go on to one of the following procedures:
- To configure a firewall filter, see Configuring a Firewall Filter for Packet Capture (Optional).
- To check the configuration, see Verifying Packet Capture.
Table 175: Configuring Packet Capture on an Interface
Task | J-Web Configuration Editor | CLI Configuration Editor |
|---|---|---|
Navigate to the Interfaces level in the configuration hierarchy, and select an interface for packet capture—for example, fe-0/0/1. (See the interface naming conventions in the Junos OS Interfaces Configuration Guide for Security Devices.) |
| From the [edit] hierarchy level, enter edit interfaces fe-0/0/1 |
Configure the direction of the traffic for which you are enabling packet capture on the logical interface—for example, inbound and outbound. |
| Enter set unit 0 family inet sampling input output |
![]() | Note: On traffic that bypasses the flow software module (protocol packets such as ARP, OSPF, and PIM), packets generated by the routing engine are not captured unless you have configured and applied a firewall filter on the interface in the output direction. |
Configuring a Firewall Filter for Packet Capture (Optional)
To configure a firewall filter and apply it to the logical interface:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 176.
- If you are finished configuring the device, commit the configuration.
- To check the configuration, see Verifying Packet Capture.
Table 176: Configuring a Firewall Filter for Packet Capture
Task | J-Web Configuration Editor | CLI Configuration Editor |
|---|---|---|
Navigate to the Firewall level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit firewall |
Define a firewall filter dest-all and a filter term—for example, dest-term—to capture packets with a particular destination address—for example, 192.168.1.1/32. |
| Set the filter and term name, and define the match condition and its action. set firewall filter dest-all term dest-term from destination-address 192.168.1.1/32 set firewall filter dest-all term dest-term then sample accept |
Navigate to the Interfaces level in the configuration hierarchy. | In the configuration editor hierarchy, select Interfaces. | Enter set interfaces fe-0/0/1 unit 0 family inet filter output dest-all |
Apply the dest-all filter to all the outgoing packets on the interface—for example, fe-0/0/1.0. (See the interface naming conventions in the Junos OS Interfaces Configuration Guide for Security Devices.) |
|
![]() | Note: If you apply a firewall filter on the loopback interface, it affects all traffic to and from the Routing Engine. If the firewall filter has a sample action, packets to and from the Routing Engine are sampled. If packet capture is enabled, then packets to and from the Routing Engine are captured in the files created for the input and output interfaces. |
Disabling Packet Capture
You must disable packet capture before opening the packet capture file for analysis or transferring the file to an external device. Disabling packet capture ensures that the internal file buffer is flushed and all the captured packets are written to the file.
To disable packet capture:
- Navigate to the top of the configuration hierarchy in either the J-Web or CLI configuration editor.
- Perform the configuration tasks described in Table 177.
- If you are finished configuring the device, commit the configuration.
Table 177: Disabling Packet Capture
Task | J-Web Configuration Editor | CLI Configuration Editor |
|---|---|---|
Navigate to the Forwarding options level in the configuration hierarchy. |
| From the [edit] hierarchy level, enter edit forwarding-options |
Disable packet capture. |
| Enter set packet-capture disable. |
Deleting Packet Capture Files
Deleting packet capture files from the /var/tmp directory only temporarily removes the packet capture files. Packet capture files for the interface are automatically created again the next time a packet capture configuration change is committed or as part of a packet capture file rotation. You must follow the procedure given in this section to delete packet capture files.
To delete a packet capture file:
- Disable packet capture following the steps in Disabling Packet Capture.
- Using the CLI, delete the packet capture file for
the interface:
- From CLI operational mode, access the local UNIX shell:user@host> start shell%
- Navigate to the directory where packet capture files are
stored:% cd /var/tmp%
- Delete the packet capture file for the interface—for
example, pcap-file.fe.0.0.0:% rm pcap-file.fe.0.0.0%
- Return to the CLI operational mode:% exituser@host>
- From CLI operational mode, access the local UNIX shell:
- Reenable packet capture following the steps in Enabling Packet Capture (Required).
- Commit the configuration.
Hide Navigation Pane
Show Navigation Pane
Download
SHA1
