Skip to main content
KPetrov
New Member
November 12, 2015
Question

FortiManager Object creation via CLI

  • November 12, 2015
  • 15 replies
  • 51529 views

I am looking into creation of mass objects in a Fortimanager , it is currently managing two 1500 D's . I know i can create the objects in the firewalls them selves but i could not find a way to import just the objects into the manager. The firewalls have been joined to the manager already.

 

What are the CLI commands of creating objects in the manager ?

 

I use the command below on the firewalls

 

edit host_10.12.170.0

set subnet 10.12.170.0 255.255.255.0 next

 

    15 replies

    scao_FTNT
    Staff
    Staff
    November 12, 2015

    you can create a script for the config and run script on package db

     

    you can enable script function display on GUI from SS - admin settings

     

    Thanks

     

    Simon

    KPetrov
    KPetrovAuthor
    New Member
    November 17, 2015

    And what is the context of the script ? is it the same as the context that is done directly on the firewall. I would rather not do it in a script but  one by one in the CLI. Is that possible  ?

    scao_FTNT
    Staff
    Staff
    November 17, 2015

    FMG does not support run CLI to generate db config like address etc

     

    a common CLI script content is similar as FOS CLI like

     

    config firewall address     edit "FMG200D"         set comment "for testing"         set subnet 10.2.112.71 255.255.255.255     next

    end

     

    Thanks

     

    Simon

    scao_FTNT
    Staff
    Staff
    December 10, 2015

    you can not just run this CLI like on FGT side

     

    the script I mentioned is a function on FMG side

     

    so go to System Settings - Admin - Admin Settings, enable "Show Scripts", then  go to "Device Manager", you will see a new section in left tree bottom "Scripts" and go to script page, you can create a CLI script, for device db, or remote device, or package db

     

    so if you want to create many address on FMG side, you choose package db, and then copy the address CLI config into script, save script, then in script list page, you will see your newly created script, right click, you can then run script on package/ADOM db to generate the addresses

     

    Thanks

     

    Simon

    gos
    New Member
    June 9, 2016

    As mentioned earlier, you need to enable scripting and run it towards the package/adom database.

    This post didn't really sum it all up for me, so I fiddled around and wrote this little guide: http://www.networkoc.net/adding-firewall-objects-in-fortimanager-through-scripting/ 

     

    Hope this helps. =)

    victorcreed
    New Member
    December 21, 2016

    Thanks Gos! I was just about to give up on the FortiManager.

    sw2090
    SuperUser
    SuperUser
    June 14, 2017

    FMG supports the same CLI as the FMG - depending on the Firmware you have on FMG and FGT.

    I did it this way here:

     

    take objects from Backup of a FortiGate and put them into FMG as CLI Script. Set the CLI Script to be affecting the ADOM/Policypackage and then ran it once.

    I imported e.g. 100s of Web Rating Overrides in this way. 

     

    cheers 

    Sebastian

    laf
    New Member
    June 24, 2017

    Hi guys,

     

    I need to add like 30 static routes hence I give it a try for a sample script:

     

    config vdom edit root config router static edit 50 set dst 172.31.16.0 255.255.255.0 set device Trt_VPN next end

     

    Starting log (Run on database) config vdom edit root > config router static router static [parameter(s) invalid. detail: object unrecognized] Failed to commit to DB, reason(> config router static router static [parameter(s) invalid. detail: object unrecognized] ) Running script(Static routes) on DB failed

    ----------------End of Log-------------------------

    -------Executing time: Sat Jun 24 14:17:19 2017-----------

    Starting log (Run on database) config vdom edit root > config router static [parameter(s) invalid. detail: object unrecognized] Failed to commit to DB, reason(> config router static [parameter(s) invalid. detail: object unrecognized] ) Running script(Static routes) on DB failed

    ----------------End of Log-------------------------

     
    Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
    Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!