Replacing small firewalls: from running config to install script
A hardware refresh of small branch firewalls sounds easy. New box, same configuration, done. Until you count: per site a handful of LAN ports, a stack of VLANs, DHCP scopes and relays, two internet connections, local admins. Multiply by the number of sites, and every one of those lines is a chance to type a mask wrong.
The Check Point Quantum Spark appliances make this easier than most: show configuration prints the whole running config as CLI commands. So the old box already tells you what the new one needs. It just needs reshaping.
What the script does
It reads the saved show configuration output of the old gateway and writes <host>_new.conf: a script to paste on the replacement, in the order you actually do the install.
bashpython3 spark_convert.py BRANCH-FW01.txt # one gateway
python3 spark_convert.py configs/ -o new/ # a whole folder
The output has four parts, matching the steps on site:
- Zero touch. Administrators, every LAN and VLAN interface with its IP, description and DHCP settings, the second internet connection, the cluster kernel parameters, the license fetch.
- Agent installer. The installer line with its token.
- When the firewall is online. SD-WAN settings, DNS, central management, SIC and fetching the policy.
- When SIC is OK. Only then the primary internet connection moves to its static IP, so you never cut the line you're working over.
Take what belongs to the box, leave the rest
The important decision is what not to copy. The rule base, objects, VPN and HTTPS inspection come from the central management server. Copying them locally would only create a second truth. So the script takes the things that belong to the appliance itself, and nothing else:
textset interface "LAN2" ipv4-address 192.0.2.1 subnet-mask 255.255.255.0
set interface "LAN2.20" ipv4-address 198.51.100.1 subnet-mask 255.255.255.0
becomes
textset interface "LAN2" ipv4-address 192.0.2.1 subnet-mask 255.255.255.0
set interface "LAN2" state on
add interface "LAN2" vlan "20"
set interface "LAN2.20" ipv4-address 198.51.100.1 subnet-mask 255.255.255.0
A few small rules like that make the difference between a script that pastes cleanly and one that stops at line 40:
- a VLAN needs its parent interface and an
add interface ... vlanline first; - physical ports need
state on, VLANs don't; - the default
adminaccount is not copied; - an interface that relays DHCP to a central server doesn't get the local IP pool;
- a source config without a recognisable internet connection gets a clear
# WARNINGline instead of a silent gap.
The script never connects to a gateway. It reads text files and writes text files, so it can run anywhere, and the output can be reviewed before anyone is on site.
Rebuilding a lost script
The funny part: this script existed before. The first sites were converted with an earlier version, and then that script was gone. What was left were its outputs.
That turned out to be a decent specification. The rebuilt version had one hard requirement: for the same input it must produce the same layout as the files that were already used on site. Same sections, same order, same comments. The engineers doing the installs know that layout; a "better" one would only slow them down.
What I took from it
- The running config is the documentation. For small appliances it's complete, current and machine-readable. Use it.
- Decide what not to copy. Everything the management server pushes stays out of the local script.
- Order the output like the work. The script follows the steps on site, including the one that would cut you off if you did it too early.
- Keep your tools in git. Rebuilding a script from its outputs works, but once is enough.