Skip to main content
ceForti
New Member
September 17, 2021
Question

IP-MAC DHCP script

  • September 17, 2021
  • 2 replies
  • 3489 views

am trying to add bulk IP-DHCP reservation, created a script. it keeps failing.

this is the script, there 100 entries, even if i restrict it to just two entries i fails. Any idea why the script fails

 

config system dhcp server edit 3 config reserved-address edit 4 set ip 192.168.10.53 set mac 5C:87:9C:D7:67:16 set description "mylap3" next edit 5 set ip 192.168.10.54 set mac B0:FC:36:B0:90:8B set description "mylap4" next end

end

    2 replies

    lobstercreed
    New Member
    September 20, 2021

    Have you tried running it directly in CLI to see why it is failing?

     

    Obviously this is incomplete; should I assume you already have IP ranges configured for server 3?  If not, that's probably the error.

    ceForti
    ceFortiAuthor
    New Member
    September 20, 2021

    I ran that in to the CLI and its working. I have IP ranges configured too.

    sw2090
    SuperUser
    SuperUser
    September 21, 2021

    looks a bit fussy to me :)

     

    Better do this way:

     

    config system dhcp server

     edit 3

      config reserved address 

       edit 0

        set ip <ip>

        set mac <mac>

        set description <description>

       next

     

       end

      end

    end

     

    You could then repeat the edit stanze in config reserved address as often as you want and fill it with new ip/mac pair.

    edit 0 is like auto increment in fortios :) If you use it you don't need to care about the number. FortiOS does this for you then.

    Just lafter the last edit standza in config reserved address you have to have an "end" to end config reserved address stanza itself :)

    Then complete it with an end to end the edit 3 stanza and annother end to end config system dhcp server stanza.

     

    And yes try to run it on cli to see where it fails or read the error logs after executing the script.

     

    hth

    Sebastian