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.
Jonathan_Body_FTNT
Article Id 193232
Description

This article explains how to maintain FortiGate Firewall policy rule number sequencing when using import scripts.


Scope

All FortiOS versions.


Solution
Connect to the CLI of the FortiGate.  To add a new Firewall Rule set simply create the firewall policy with an id of "0", it will take the next available rule number.
FG300B3908606491 # config firewall policy
FG300B3908606491 (policy) # edit 0 -----> put 0
new entry '0' added
FG300B3908606491 (0) # set srcintf port3
FG300B3908606491 (0) # set dstintf port2
FG300B3908606491 (0) # set srcaddr all
FG300B3908606491 (0) # set dstaddr all
FG300B3908606491 (0) # set service ANY
FG300B3908606491 (0) # set schedule always
FG300B3908606491 (0) # show
config firewall policy
edit 7 -------------> ID 7 has been given to this policy
set srcintf "port3"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set schedule "always"
set service "ANY"
next
end
FG300B3908606491 (0) # next
FG300B3908606491 (policy) #
If using an import script then always have the rule number set to "0" so that the sequencing within FortiOS is respected when the script runs.

Contributors