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 386014
Description This article describes how to add per-device mapping to VLANs in FortiSwitch Manager.
Scope FortiManager.
Solution

Per-Device mapping for VLANs in FortiSwitch Manager can be added by following in bulk by using Script and also via JSON API:

 

  1. Using Script: Go under Device Manager -> Scripts -> Create New Script and set the 'Run Script on' to 'Policy Package or ADOM Database' and run it on any package:

config fsp vlan

    edit "<VLAN_NAME>"

        set vlanid <VLAN_ID>

        config dynamic_mapping

            edit "<DEVICE_NAME>"-"<VDOM>"

                set _dhcp-status enable

                config interface

                    set ip <IP> <MASK>

                    set vlanid <VLAN_ID>

                end

                config dhcp-server

                    set default-gateway <IP>

                    set netmask <MASK>

                    set dns-service default

                    set ntp-service default

 

                    config ip-range

                        edit 1

                            set start-ip <IP>

                            set end-ip <IP>

                        next

                    end

                end

            next

        end

    next

end

 

  1. Using JSON API: Use the API request below to add per-device mapping for VLANs in FortiSwitch Manager:

 

{
    "method": "add",
    "params": [
        {
            "data": [
                {
                    "interface": {
                        "ip": [
                            "{{IP_ADDRESS}}",
                            "{{NETMASK}}"
                        ],
                        "secondary-IP": 0,
                        "secondaryip": null,
                        "vlanid": {{VLAN_ID}}
                    },
                    "dhcp-server": {
                        "auto-configuration": 1,
                        "auto-managed-status": 1,
                        "conflicted-ip-timeout": 1800,
                        "default-gateway": "{{IP_ADDRESS}}",
                        "id": 0,
                        "ip-range": [
                            {
                                "start-ip": "{{DHCP_START_IP}}",
                                "end-ip": "{{DHCP_END_IP}}",
                                "id": 1
                            }
                        ],
                        "lease-time": 604800,
                        "netmask": "{{NETMASK}}",
                        "server-type": 1,
                        "status": 1
                    },
                    "_scope": [
                        {
                            "name": "{{DEVICE_NAME}}",
                            "vdom": "{{VDOM}}"
                        }
                    ],
                    "_dhcp-status": 1
                }
            ],
            "url": "/pm/config/adom/{{ADOM_NAME}}/obj/fsp/vlan/{{VLAN_NAME}}/dynamic_mapping"
        }
    ],
    "id": 1,
    "session": "{{session}}"
}

 

Related documents:

Add a Script
FortiSwitch VLANs
Technical Tip: Using FortiManager API
Fortinet Development Network (FNDN) - FortiManager