FortiManager
FortiManager supports network operations use cases for centralized management, best practices compliance, and workflow automation to provide better protection against breaches.
farhanahmed
Staff
Staff
Article Id 332878
Description The article describes how to create an IPSec Template in FortiManager and assign it to a managed FortiGate using JSON API.
Scope FortiManager v7.2.5, v7.4.3, v7.6, FortiGate, API.
Solution

Creating the IPSec Template via JSON API involves the below steps:

  • Create the IPSec Template.
  • Create tunnel.
  • Add IPSec phase1 to the tunnel.
  • Add IPSec phase2 to the tunnel.
  • Assign the template to a managed FortiGate.

  1. Create the IPSec Template.

    {
      "method": "set",
      "params": [
        {
            "data": {
                        "name": "TEMPLATE_NAME",
       
                        "template setting": {
                            "stype": "_ipsec",
                            "widgets": [
                                "_ipsec"
                            ]
                        },
                        "type": "template"
                    },
            "url":"/pm/template/_ipsec/adom/ADOM_NAME/"
        }
      ],
      "session": "{{session}}",
      "id": 1
    }

    Sample output:

    1.png

  2. Create Tunnel:

    {
        "method": "set",
        "params": [
            {
                "data": {
                    "dynamic_mapping": null,
                    "var-list": null,
                    "seq": 1,
                    "action": "conf-ipsec-template",
                    "model": "all",
                    "value": {
                        "automatic-routing": "disable",
                        "local-addr-type": "dynamic",
                        "name": "TUNNEL_NAME",
                        "nat": "disable",
                        "remote-subnet": [
                            "IP_ADDRESS/SUBNET MASK"
                        ]
                    }
                },
                "url": "/pm/config/adom/ADOM_NAME/template/_ipsec/TEMPLATE_NAME/action-list/"
            }
        ],
        "session": "{{session}}",
        "id": 1
    }

    Sample Output:

    2.png

     

  3.  Add IPSec phase1 to the tunnel:

    {
        "method": "set",
        "params": [
            {
                "data": {
                    "name": "TUNNEL_NAME",
                    "type": 0,
                    "interface": [
                        "<interface>"
                    ],
                    "local-gw": "<LOCAL GW_IP>",
                    "localid": "<LOCAL_ID>",
                    "dpd": 3,
                    "nattraversal": 1,
                    "dhgrp": 12,
                    "proposal": [
                        "aes256-sha256"
                    ],
                    "keylife": 86400,
                    "authmethod": 1,
                    "peertype": 1,
                    "add-gw-route": 0,
                    "distance": 15,
                    "priority": 1,
                    "remote-gw": "<REMOTE_GW_IP>",
                    "psksecret": [
                        "PSKSECRET"
                    ]
                },
                "url": "/pm/config/adom/ADOM_NAME/template/_ipsec/TEMPLATE_NAME/vpn/ipsec/phase1-interface/"
            }
        ],
        "session": "{{session}}",
        "id": 1
    }

    Sample Output:
     
    3.png 

  4. Add IPSec phase2 to the tunnel:

    {
        "method": "set",
        "params": [
            {
                "data": {
                    "name": "TUNNEL_NAME",
                    "phase1name": [
                        "TUNNEL_NAME"
                    ],
                    "proposal": [
                        "aes256-sha256",
                        "3des-md5"
                    ],
                    "replay": 1,
                    "auto-negotiate": 1,
                    "src-subnet": [
                        "0.0.0.0",
                        "0.0.0.0"
                    ],
                    "src-addr-type": 0,
                    "src-port": 0,
                    "dst-addr-type": 0,
                    "dst-port": 0,
                    "keylifeseconds": 43200,
                    "dst-subnet": [
                        "0.0.0.0",
                        "0.0.0.0"
                    ]
                },
                "url": "/pm/config/adom/ADOM_NAME/template/_ipsec/TEMPLATE_NAME/vpn/ipsec/phase2-interface/"
            }
        ],
        "session": "{{session}}",
        "id": 1
    }

    Sample Output:

    4.png

     

  5. Assign the template to a managed FortiGate:

    {
        "method": "set",
        "params": [
            {
                "data": {
                    "name": "FORTIGATE",
                    "vdom": "VDOM"
                },
                "url": "/pm/template/_ipsec/adom/ADOM_NAME/TEMPLATE_NAME/scope member"
            }
        ],
        "session": "{{session}}",
        "id": 1
    }

    Sample Output:
     
    5.png

     

  • Verify the IPSec Template:

    {
        "method": "get",
        "params": [
            {
                "url": "/pm/template/_ipsec/adom/ADOM_NAME"
            }
        ],
        "session": "{{session}}",
        "id": 1
    }

    Output:
     
    6.png

     

  • Check on FortiManager GUI -> Device Manager -> Provisioning Templates -> IPSec Template:
     
    7.png

     

  • For a complete list of FortiManager API calls and details, refer to Fortinet Development Network (FNDN).

 

Related documents:

Technical Tip: Using FortiManager API

Fortinet Development Network (FNDN) - FortiManager

Technical Tip: Managing the JSON API call with Postman and how to delete, create and update an ADOM ...