FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
vrajendran
Staff
Staff
Article Id 197062

Description

 

This article describes a method to count the total number of firewall policies on a FortiGate.

CLI commands listed below will display the total number of policies, and how many policies are enabled or disabled.

Scope

 
FortiOS firmware (all versions).


Solution

 

Using the command modifier '| grep' instructs the firewall to 'search for' the information that follows (in quotes if multiple words are used).

Using the command modifier '-c' instructs the firewall to only 'count' the number of occurrences.


The command to count the total number of firewall policies:

 

sh full-configuration firewall policy | grep -c 'set status'

 

To count enabled firewall policies:

 

sh full-configuration firewall policy | grep -c 'set status enable'

 

To count disabled firewall policies.

 

sh full-configuration firewall policy | grep -c 'set status disable'

 

This can be applied to all contexts, not only to firewall policies.

Note: this only works per VDOM, and does not display a summary of all vdoms. To see the output from another VDOM, that VDOM needs to be entered first.