Skip to main content
ycho
Staff
Staff
December 24, 2019

Technical Tip: How to export IPv4 Policies from FortiGate to Excel.

  • December 24, 2019
  • 0 replies
  • 146415 views

Description


When troubleshooting or verifying lots of IPv4 policies, it cannot be directly extracted on FortiGate to a CSV file.
Only FortiManager can extract IPv4 policies to the CSV files.

This article describes how to extract IPv4 Policies on the FortiGate and convert them to CSV files with good visibility.


Note that Fortinet Technical Support does not provide any troubleshooting assistance for extracting IPv4 Policies from your FortiGate config file to a CSV file.


It is possible to use the below method for the below 6.4 versions.

Scope

 

FortiGate.


Solution

 

1). Use this script fgpoliciestocsv.py.

Download it via the link below:
https://github.com/maaaaz/fgpoliciestocsv/find/master?q=

 
KB2.jpg
 

2). Export the configuration of the FortiGate, by the backup or command line (FortiGate configuration file: 'Fortinet_2019121….conf').

 
 
KB3.jpg
 

3). In the configuration file, search the 'config firewall policy', then copy and paste IPv4 policies to cfg file (cfg file: 'fgfw.cfg').

 
 
KB4.jpg
 
 
KB5.jpg
 
4). Execute the script fgpolciestocsv.py.

- Upload files (fgfw.cfg, fgpoliciestocsv.py) to Unix or Linux based OS.
Upload these files via https://winscp.net/eng/download.php if WinSCP is used.
 
 
KB6.jpg
 
KB7.jpg
 
 
5). Input the command of 'fgpoliciestocsv.py -i [cfg file name].cfg' find 'policies-out.csv' file.
Use WINSCP to move the file to the Windows OS and run it in Excel.
 
 
 
 
 
 
6). Convert Text to columns in the Excel going to Delimited -> Tab and Semicolon.
 
 


If you want to download all the policy details including the byte counts from the firewall GUI on the 7.0.2 and above version follow the below steps.

To export the firewall policy list to a CSV or JSON file:

  1. Go to Policy & Objects > Firewall Policy.
  2. In the toolbar above the list, click Export.
  3. Select CSV or JSON.


sourav_0-1649404729348.png

 

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!