DHCP statics mapping are not applied until I manual stop and restart dhcpd

  • Hello,

    I work with static mappings, since many releases ago I need to manually stop and restar the dhcpd for new static mappings to take effect.

    It didn't work in 2.2.x and now that I finally updated to 2.3.2_1 it remains the same.

    If I enter a static mapping and click Save, the device recently assigned just get an IP from the DHCP pool Range, if I manually go to Status->Services and stop and start dhcps, then the device immediatelly get the correct static assigned IP.

  • LAYER 8 Global Moderator

    are you deleting the clients old lease?  Are you having the client renew after you delete the old lease.

    I add statics all the time, don't have to restart.  You just have to make sure you delete the old lease, and then have the client renew or ask for a lease.  It then gets the new reservation..

  • None of your suggestions apply to my case.

    We are a WISP and the static mapping are entered in pfsense a day before the instalation of the device, so pfsense never see the device connected prior to entering the static mapping. So devices do not have old leases.

    If I Enter the static mapping a day early and forget to stop and restart the dhcpd service, the new device (never before on the network) just get an ip from the pool.

    We have 500+ mapping. Not sure if relevant.

  • Banned

    Yeah, you must be special or doing something wrong.

  • LAYER 8 Global Moderator

    Well I don't have anywhere close to 500 static leases..  But shouldn't really matter if you have 5 or 5000.. I have put in statics for clients that have never gotten a lease and they get the reservation I put in.  I do not have to manually stop and start the service.

    When you create the static do you see it in the conf file?  When you hit the apply changes that pops up once you add the static, this will restart the service, you can see it in the dhcp log..

    If your not hitting apply, then no the new lease reservation would not be put into the conf file..

    So in your /var/dhcpd/etc you will see a conf file, I just added this test one.. Hit apply, see in my logs that dhcpd restarted.

    host s_lan_7 {
            hardware ethernet 00:00:00:aa:bb:cc;

    So then created another test reservation, and don't hit apply and its not in there.  so go away from the dhcp server section, then come back the apply button is still there.  Hit apply, then you can see the entry in the conf file and in the logs you see the dhcp server restart.

  • I can see the dhcp daemon restarting in the logs. Since it wasn't working in my 2.2 installation (highly modified, not standard) maybe I've not tested it thoroughly in current version (now running standard, not modified)

    I will retest and get back.

  • I can confirm there is in fact a problem.

    I enter the DHCP static mapping, clic save, then apply. And now connect the previously not connected equipment and it gets an IP from the pool (not the static one).

    Stopping and restarting the dhcpd service, and now renew the dhcp on the device and it work as expected (no need to erase the incorrect pool ip lease in dhcp)

    In logs I see the dhcpd restarting with the apply button, and in the conf file in /var/dhcpd/etc I can see the reservation is there in the form:

    host s_lan_158 {
            hardware ethernet 80:2a:a8:78:7f:0d;
    	option host-name "(removed)";

    The ONLY thing that I imagine is happening is: Since I have a very large number of static mappings (500+) maybe the configuration file is written before the dhcpd daemon restart, and it take the previous version. But is only speculation.

    Attached images show: DHCP reservation, DHCP saved and applied (no apply message), and later the equipment given an IP from the pool.

    ![dhcp reservation.png](/public/imported_attachments/1/dhcp reservation.png)
    ![dhcp reservation.png_thumb](/public/imported_attachments/1/dhcp reservation.png_thumb)
    ![dhcp applied.png](/public/imported_attachments/1/dhcp applied.png)
    ![dhcp applied.png_thumb](/public/imported_attachments/1/dhcp applied.png_thumb)

  • LAYER 8 Global Moderator

    "Since I have a very large number of static mappings (500+) maybe the configuration file is written before the dhcpd daemon restart"

    I think you mean the file is not finished writing until after the restart?  That could make sense, ie your running with previous config without the reservation..

    Guess that is possible..  Like I said I don't have anywhere close to that many statics, and have never run into such a problem.  But the theory has some merit I guess.

    Off the top, guess you could just do your manual stop and start of the dhcpd.  Maybe there is some code that could be tweaked to make sure that any changes to the conf are completed before the dhcp restarts.  I would think but not sure that the file would be written when you hit save and create the new reservation.  And then just hitting apply restarts the service to reload the new conf..

    What if you wait a few seconds after creating the new reservation before hitting the apply button?

  • I will test waiting before click apply.

    But I think save just write to the pfsense config.xml file and Apply recreate dhcpd conf file and restart the daemon.

    I will test it later and try to understand how pfsense reconstruct the dhcp conf file and restart the service in the source files.