Related Documentation
Example: Configuring Statistics Collection for a Standard Firewall Filter
This example shows how to configure and apply a stateless firewall filter that collects data according to parameters specified in an associated accounting profile.
Requirements
Firewall filter accounting profiles are supported for all traffic types except family any.
No special configuration beyond device initialization is required before configuring this example.
Overview
In this example, you create a firewall filter accounting profile and apply it to a stateless firewall filter. The accounting profile specifies how frequently to collect packet and byte count statistics and the name of the file to which the statistics are written. The profile also specifies that statistics are to be collected for three firewall filter counters.
Topology
The firewall filter accounting profile filter_acctg_profile specifies that statistics are collected every 60 minutes, and the statistics are written to the file /var/log/ff_accounting_file. Statistics are collected for counters named counter1, counter2, and counter3.
The IPv4 stateless firewall filter named my_firewall_filter increments a counter for each of three filter terms. The filter is applied to logical interface ge-0/0/1.0.
Configuration
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode.
To configure this example, perform the following tasks:
- Configure an Accounting Profile
- Configure a Firewall Filter That References the Accounting Profile
- Apply the Firewall Filter to an Interface
- Confirm Your Candidate Configuration
- Clear the Counters and Commit Your Candidate Configuration
CLI Quick Configuration
To quickly configure this example, copy the following configuration commands into a text file, remove any line breaks, and then paste the commands into the CLI at the [edit] hierarchy level.
Configure an Accounting Profile
Step-by-Step Procedure
To configure an accounting profile:
Create the accounting profile filter_acctg_profile.
[edit]user@host# edit accounting-options filter-profile filter_acctg_profileConfigure the accounting profile to collect filter profile statistics (packet and byte counts) for three counters.
[edit accounting-options filter-profile filter_acctg_profile]user@host# set counters counter1user@host# set counters counter2user@host# set counters counter3
Configure a Firewall Filter That References the Accounting Profile
Step-by-Step Procedure
To configure a firewall filter that references the accounting profile:
Create the stateless firewall filter my_firewall_filter.
[edit]user@host# edit firewall family inet filter my_firewall_filterApply the filter-accounting profile filter_acctg_profile to the firewall filter.
[edit firewall family inet filter my_firewall_filter]user@host# set accounting-profile filter_acctg_profileConfigure the first filter term and counter.
[edit firewall family inet filter my_firewall_filter]user@host# set term term1 from protocol ospfuser@host# set term term1 then count counter1user@host# set term term1 then discardConfigure the second filter term and counter.
[edit firewall family inet filter my_firewall_filter]user@host# set term term2 from source-address 10.108.0.0/16user@host# set term term2 then count counter2user@host# set term term2 then discardConfigure the third filter term and counter.
[edit firewall family inet filter my_firewall_filter]user@host# set term accept-all then count counter3user@host# set term accept-all then accept
Apply the Firewall Filter to an Interface
Step-by-Step Procedure
To apply the stateless firewall filter to a logical interface:
Configure the logical interface to which you will apply the stateless firewall filter.
[edit]user@host# edit interfaces ge-0/0/1 unit 0 family inetConfigure the interface address for the logical interface.
[edit interfaces ge-0/0/1 unit 0 family inet]user@host# set address 10.1.2.3/30Apply the stateless firewall filter to the logical interface.
[edit interfaces ge-0/0/1 unit 0 family inet]user@host# set filter input my_firewall_filter
Confirm Your Candidate Configuration
Step-by-Step Procedure
To confirm your candidate configuration:
Confirm the configuration of the accounting profile by entering the show accounting-options configuration mode command. If the command output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
[edit]user@host# show accounting-optionsfilter-profile filter_acctg_profile {file ff_accounting_file;interval 60;counters {counter1;counter2;counter3;}}Confirm the configuration of the stateless firewall filter by entering the show firewall configuration mode command. If the command output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
[edit]user@host# show firewallfamily inet {filter my_firewall_filter {accounting-profile filter_acctg_profile;term term1 {from {protocol ospf;}then {count counter1;discard;}}term term2 {from {source-address {10.108.0.0/16;}}then {count counter2;discard;}}term accept-all {then {count counter3;accept;}}}}Confirm the configuration of the interfaces by entering the show interfaces configuration mode command. If the command output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
[edit]user@host# show interfacesge-0/0/1 {unit 0 {family inet {filter {input my_firewall_filter;}address 10.1.2.3/30;}}}
Clear the Counters and Commit Your Candidate Configuration
Step-by-Step Procedure
To clear the counters and commit your candidate configuration:
- From operational command mode, use the clear firewall all command to clear the statistics for all firewall filters.
To clear only the counters incremented in this example, include the name of the firewall filter.
[edit]user@host> clear firewall filter my_firewall_filter Commit your candidate configuration.
[edit]user@host# commit
Verification
To verify that the filter is applied to the logical interface, run the show interfaces command with the detail or extensive output level.
To verify that the three counters are collected separately, run the show firewall filter my_firewall_filter command.
user@host> show firewall filter my_firewall_filter
Filter: my_firewall_filter Counters: Name Bytes Packets counter1 0 0 counter2 0 0 counter3 0 0