FortiManager
FortiManager supports network operations use cases for centralized management, best practices compliance, and workflow automation to provide better protection against breaches.
eelvira
Staff
Staff
Article Id 337431
Description

 

This article describes how to modify 'fmg-source-ip' parameter from FortiManager, using the TCL script.

 

FortiGate parameter 'fmg-source-ip', under system central-management, is used to specify the FortiGate source-IP when establishing communication between FortiGate and FortiManager.

 

Scope

 

FortiManager, all firmware.

 

Solution

 

Modifying the fmg-source-ip parameter is not allowed in the FortiManager Device Database. For that reason, CLI Templates and scripts in 'Device Database' cannot be used. The user must execute the script at 'Remote FortiGate Directly (via CLI)'.

 

It is possible to use the TCL script to automate the task on several FortiGates using a single script when the source-IP interface name remains the same.

 

  1. Configure the following CLI settings.

FMG # config system admin setting
(setting) set show_tcl_script enable
(setting) end

 

  1. Navigate from Device Manager -> Scripts -> Select 'Create new'.

     

     

  2. Create a TCL script as shown in the screenshot, using the following script text. Example:

     

    #!
    proc do_cmd {cmd} {
    puts [exec "$cmd\n" "# " 15]
    }

    # Get IP address from desired interface and vdom.
    do_cmd "config vdom"
    do_cmd "edit root"
    do_cmd "config system interface"
    do_cmd "edit port4"
    set query [exec "show\n" "# "]
    #puts $query
    set output [split $query "\n"]
    #Find IP address and puts $ip
    regexp {(?:\d+\.){3}\d+} $output ip
    do_cmd "end"
    do_cmd "end"

    # configure fmg-source-ip
    do_cmd "config global"
    do_cmd "config system central-management"
    do_cmd "set fmg-source-ip $ip"
    do_cmd "end"

    tcl-script.png

     

     

  3. Run the script in the required FortiGates.

     

    tcl-script-result.png

     

Note: Modify the TCL script depending on interface names and VDOM configuration.