Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
SecurityPlus
Contributor II

Import Addresses Script To Create Script File

I need to import a few hundred IP addresses into a FortiGate 60E firmware 6.0.7 and put them into a single address group. I can get the IPv4 addresses into a csv file. Is there an easy way to import them and to put them into the group. I see a document here: https://kb.fortinet.com/kb/documentLink.do?externalID=FD45633 describing the script needed to import the addresses and groups but it would take quite a while to build the script file. Is there a script that I could use to populate the script file?

 

Is it correct then that I can upload the script into the FortiGate via: System / Advanced / Configuration Scripts / Upload and Run a New Script?

 

2 REPLIES 2
ede_pfau
Esteemed Contributor III

May I humbly refer you to my website at https://www.beneicke-edv.de/support/tools/#ext_blacklists where I have published a python script some time ago which tackles exactly this problem.

 

Given a simple text file with one IP address per line, it will create a FortiOS batch command file suitable for importing into a running config.

 

Script options allow to customize the output for small/medium/big FGT models (as the maximum number of addresses per address group varies among these), split the output into several batch command files etc. You can even supply FQDNs instead of IP addresses and the script will resolve them before creating the address object.

It's written in python 2.7 but should (not tested) run in python 3.x with minor changes, if any.

 


Ede

"Kernel panic: Aiee, killing interrupt handler!"
Ede"Kernel panic: Aiee, killing interrupt handler!"
SecurityPlus

Thank you for the help. I will review your suggestions.

Labels
Top Kudoed Authors