Hi,
we have 4 FortiGate firewall each has around 3000 polices, we want export them and import them into single FortiGate firewall. the question how can i use notepad++ or any other editor to have auto sequential number for policies to make sure no policy ID will be same from all firewalls.
in plain English i want i want to find "edit" and have auto incremental number after it.
Hello,
Manual configuration edition is not supported since it can lead to mistakes due to lack of input validation. You may consider to use FortiConverter instead. Please find the details by following the link below:
https://www.fortinet.com/products/next-generation-firewall/forticonverter
I believe it will be difficult/not possible to do with just text editors, but can be done with the help of a python script as below.
______________________________________________________
import sys
import re
def replace_edits_with_sequence(txt_path):
with open(txt_path, 'r') as file:
lines = file.readlines()
sequence_counter = 1
lines = [re.sub(r'^edit\d+', 'edit', line, flags=re.IGNORECASE) for line in lines]
def repl(match):
nonlocal sequence_counter
replacement = f'edit{sequence_counter}'
sequence_counter += 1
return replacement
lines = [re.sub(r'\bedit\b', repl, line, flags=re.IGNORECASE) for line in lines]
updated_txt_path = txt_path.replace('.txt', '_updated.txt')
with open(updated_txt_path, 'w') as file:
file.writelines(lines)
print(f"File updated and saved as: {updated_txt_path}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <input_file.txt>")
sys.exit(1)
input_file = sys.argv[1]
replace_edits_with_sequence(input_file)
______________________________________________________
Save the above script as <name>.py file (example script.py) and then save your consolidated policies file in .txt file (exmple Consolidatedpolicies.txt) on same folder.
Run the script as > script.py Consolidatedpolicies.txt
This will give output as Consolidatedpolicies_updated.txt with corrected sequence numbers.
Select Forum Responses to become Knowledge Articles!
Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.
User | Count |
---|---|
1737 | |
1107 | |
752 | |
447 | |
240 |
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.