Created on 04-20-2022 02:49 AM Edited on 12-08-2023 06:19 AM By Stephen_G
Description
This article is a use-case scenario that provides the network administrator the possibility to quickly revert a bad config remotely and automatically in case the newly uploaded config removes routing or produces loss of access to the FortiGate.
Surely, a remote FortiManager or FortiGateCloud can help in such cases, but that also implies that the internet access is still available after the config change. This also applies to distributed deployments, such as SD-WAN environments, where it is problematic to lose management connectivity to a unit when changes related to routing are being applied.
Scope
Automatically restoring or rolling back a FortiGate configuration change in case of unsuccessful config load, without the need for local access to the unit.
It is focused on isolated environments, where no FortiManager or other tool exists to push the configuration to the FortiGate.
Solution
The regular rollback can be accomplished in a few ways:
config system global
set cfg-save revert
set cfg-revert-timeout 600 <- The default is 600s of admin session being idle.
end
execute cfg save <- Execute this when all CLI changes have been made.
See related article Technical Tip : Using the save option 'set cfg-save revert' to automatically reboot and revert to a ....
As a result, it is necessary to have the FortiGate auto-reload a previously good config.
Possible ways to achieve this:
Steps to take:
In this configuration, it is necessary to add the following automation-stitch lines.
FortiOS 7.0.x (the delay is now added to the 'automation-stitch' as opposed to '-action' in 6.4.x):
config system automation-trigger
edit "started"
set event-type event-log
set logid 32009
next
end
config system automation-action
edit "restorecfg"
set action-type cli-script
set script "exec restore config flash 1y"
set accprofile "super_admin"
next
end
config system automation-stitch
edit "cfg_reload"
set trigger "started"
config action
edit 1
set action "restorecfg"
set delay 300
set required enable
next
end
next
end
FortiOS 6.4.x:
config system automation-trigger
edit "cfg_reload"
set event-type event-log
set logid 32009
next
end
config system automation-action
edit "reboot"
set action-type cli-script
set delay 300
set required enable
set script "exec restore config flash 1y"
set accprofile "super_admin"
next
end
config system automation-stitch
edit "cfg_reload"
set trigger "cfg_reload"
set action "reboot"
next
end
Note:
This script is triggered by the 'FortiGate started' log (set logid 32009) and reloads the previous configuration (revision #1) after the delay (in seconds) has passed.
This is the time available to perform the checks and disable/remove the script manually.
Load this new configuration file into the FortiGate (GUI -> Username -> Configuration -> Restore -> Upload ).
config system automation-stitch
delete "cfg_reload"
end
config system automation-action
delete "reboot"
end
config system automation-trigger
delete "cfg_reload"
end
Note:
These tests were performed in FortiOS 6.4.8 and 7.0.5.
The automation trigger can be set up differently. But if 'Reboot' is selected as action, run the 'exec reboot' command manually (it will not be triggered by a config restore action).
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.