Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
leroy_hack
New Contributor

DHCP server setup

I want to migrate from an existing DHCP server to using the fortigate as the DHCP server. Is there a way to program the DHCP server on the forigate including MAC reservations prior to putting it into service? I tried to add the reservations, but when I turned the DHCP server off and back on again, the entries were gone. 

 

Maybe it has to be done via a script? Is there an simple example script? Or a best practice example?

 

Using firmware 5.6.2 build1486

6 REPLIES 6
lobstercreed
Valued Contributor

Always best to do some searching on the forum before posting.  :) 

 

There was a recent thread regarding this:

https://forum.fortinet.com/tm.aspx?m=190549

 

leroy_hack

I did read that thread and while it addressed adding MAC addresses in bulk, it didn't address the question that I am asking: What is the best way to program the DHCP server offline?

 

When I use the GUI, the entries are not persistent when I turn off the DHCP server. The DHCP server has to be on to add the MAC address reservations, but when I turn it off again, the MAC address reservations are gone.

lobstercreed

Why are you turning it on and off?  That's never going to work.  I'm also not sure what you mean by "offline".  You can do any CLI changes (script) offline and restore the config -- as long as you haven't made any mistakes everything will work great.  So you can do everything in one fell swoop.  Turn on DHCP and load all your reservations, etc.  That's what that other thread was trying to help with...

leroy_hack

There is one DHCP in use that I want to decommission and start using the fortigate to DHCP requests.  My plan was to program the fortigate ahead of time, then we we verify the entries are correct etc, turn off the old DHCP and turn on the fortigate. To do that, the DHCP server in the fortigate would have to be offline or out of service or not actively serving requests - however you prefer to say it.

 

To test this, I tried to program the fortigate but the only way to get to the settings in the GUI is to turn on the DHCP server. I made some basic config changes to the DHCP settings and turned it off so there were no conflicts on the network. That's when I realized the fortigate deletes its config when it is turned off. That is odd behavior to me. Outside of memory-only applications, it is pretty rare that stopping a service  deletes parts of the configuration.

 

Taking the entire unit down to upload a complete config for one service doesn't make much sense to me either.

 

It is pretty easy to mess up a network with some miss-entered DHCP reservations. Not having a way to test and verify it before live deployment didn't make sense to either. 

 

I figured there had to be another way. Not that it matters, but  that is why I was asking. 

lobstercreed

Fair point, but DHCP is more of an ancillary function on a FortiGate, so it isn't designed with robustness in mind.  If you view the code in CLI you will see that the DHCP server is a separate config under config system dhcp server and each element is REQUIRED to have an interface set.  This is why when you remove it from an interface it deletes the config entirely.

 

However, I think you can still do what you want.  When you do your migration all you have to do is paste the code into the CLI and it will work.  If you want to set it up from GUI first you can then get the CLI config by doing show system dhcp server and then copy it out into a text editor.  Turn it off, then when you're ready just paste the config back into CLI and it should be turned back on just as you had it before (all the reservations, etc as well).

 

EDIT: Actually I see that from CLI you can set the DHCP server to disable so that it doesn't delete your config.

 

config system dhcp server

edit 1

set status disable

next

end

 

If you check the GUI after this you will see that the DHCP server is off but if you turn it back on (from CLI or GUI) all your config should be there.

sw2090
Honored Contributor

There is no need to take the complete unit down or restore the complete config.

You could just write (or generate) the part of the config cencerning this dhcp server and then apply it via clli or gui.

Just keep in mind that in gui dhcp server is shown in the interface setup while on cli it is its own part (config system dhcp server)

 

-- 

"It is a mistake to think you can solve any major problems just with potatoes." - Douglas Adams

-- "It is a mistake to think you can solve any major problems just with potatoes." - Douglas Adams
Labels
Top Kudoed Authors