Import Addresses Script To Create Script File

Author
SecurityPlus
Gold Member
  • Total Posts : 287
  • Scores: 4
  • Reward points: 0
  • Joined: 2014/08/11 18:41:34
  • Status: offline
2019/12/02 12:12:04 (permalink)
0

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?
 

FWF30E, FG50E, FWF50E, FG60D, FWF60D, FG60E, FG80E, FG100D
FortiOS 5.2, 5.4, 5.6, and 6.0
FortiSwitch FS-224E-POE
FAP-221E, FAP-221C
#1

2 Replies Related Threads

    ede_pfau
    Expert Member
    • Total Posts : 6127
    • Scores: 496
    • Reward points: 0
    • Joined: 2004/03/09 01:20:18
    • Location: Heidelberg, Germany
    • Status: offline
    Re: Import Addresses Script To Create Script File 2019/12/02 13:33:58 (permalink)
    0
    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!"
    #2
    SecurityPlus
    Gold Member
    • Total Posts : 287
    • Scores: 4
    • Reward points: 0
    • Joined: 2014/08/11 18:41:34
    • Status: offline
    Re: Import Addresses Script To Create Script File 2019/12/02 14:24:09 (permalink)
    0
    Thank you for the help. I will review your suggestions.

    FWF30E, FG50E, FWF50E, FG60D, FWF60D, FG60E, FG80E, FG100D
    FortiOS 5.2, 5.4, 5.6, and 6.0
    FortiSwitch FS-224E-POE
    FAP-221E, FAP-221C
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 5.5