Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    DHCP server is not releasing expired lease

    Scheduled Pinned Locked Moved DHCP and DNS
    31 Posts 4 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • johnpozJ
      johnpoz LAYER 8 Global Moderator @guile
      last edited by johnpoz

      @guile so seems I don't even have to change my scope - clearly all of my IPs from that scope are expired already..

      So I just need to fire up something on that vlan and see if it gets one of those expired leases. I don't normally fire up stuff on that vlan - other than to just temp get it on the network, then I assign it a reservation (outside the scope).

      expired.jpg

      I don't recall having any issues recently - and from looking at the dates of the expired, does seem that some have been reused since they are active.. see like 105, 106 and 107.. Hmmm have I not given something a reservation?

      But this should make it easy to try and duplicate the problem he is seeing.

      edit: from what I see on my leases - it does seem to be handing out expired ones already.. But when I get back I will test and document.. And we can put in a redmine about it to see if anyone else is having the issue. And should be simple enough to force a example by just using a small lease and scope - and then letting them expire and fire up something with a different mac, ec.

      An intelligent man is sometimes forced to be drunk to spend time with his fools
      If you get confused: Listen to the Music Play
      Please don't Chat/PM me for help, unless mod related
      SG-4860 24.11 | Lab VMs 2.8, 24.11

      G 1 Reply Last reply Reply Quote 0
      • G
        guile @johnpoz
        last edited by

        @johnpoz try to fire up some smartphone with randomize MAC active. But first forget the wifi and rejoin.

        S 1 Reply Last reply Reply Quote 0
        • S
          SteveITS Galactic Empire @guile
          last edited by

          @guile Since you said December, are you on an old version or does it persist across reboots/version upgrades?

          Some sort of odd file corruption?

          Pre-2.7.2/23.09: Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
          When upgrading, allow 10-15 minutes to restart, or more depending on packages and device speed.
          Upvote 👍 helpful posts!

          G johnpozJ S 3 Replies Last reply Reply Quote 0
          • G
            guile @SteveITS
            last edited by

            @SteveITS not me. -> @sdugoten

            1 Reply Last reply Reply Quote 0
            • johnpozJ
              johnpoz LAYER 8 Global Moderator @SteveITS
              last edited by johnpoz

              @SteveITS said in DHCP server is not releasing expired lease:

              Some sort of odd file corruption?

              Maybe because I can not duplicate the problem - as you saw before my dhcp scope is used.. All the IP in the scope have been handed out.. So I know just phone to that vlan, letting it use a different mac (private stuff)..

              And you can see it grabbed an old expired lease .104, and assigned it to my phone connection..

              noissue.jpg

              What specific version of pfsense are you on? I am on 23.05.1 - I could try and duplicate the problem on my old 2.6 vm, or 2.7 vm - but take me a bet to test it out..

              An intelligent man is sometimes forced to be drunk to spend time with his fools
              If you get confused: Listen to the Music Play
              Please don't Chat/PM me for help, unless mod related
              SG-4860 24.11 | Lab VMs 2.8, 24.11

              S 1 Reply Last reply Reply Quote 0
              • S
                sdugoten @SteveITS
                last edited by

                @SteveITS it persist across version upgrade and reboots

                1 Reply Last reply Reply Quote 0
                • S
                  sdugoten @johnpoz
                  last edited by sdugoten

                  @johnpoz said in DHCP server is not releasing expired lease:

                  @SteveITS said in DHCP server is not releasing expired lease:

                  Some sort of odd file corruption?

                  Maybe because I can not duplicate the problem - as you saw before my dhcp scope is used.. All the IP in the scope have been handed out.. So I know just phone to that vlan, letting it use a different mac (private stuff)..

                  And you can see it grabbed an old expired lease .104, and assigned it to my phone connection..

                  noissue.jpg

                  What specific version of pfsense are you on? I am on 23.05.1 - I could try and duplicate the problem on my old 2.6 vm, or 2.7 vm - but take me a bet to test it out..

                  I am on 23.05.01

                  Actually, I have already removed all expired lease so I can't reproduce it right now until I have more expired lease. However, I did find a lot of similar case that wasn't resolved

                  https://forum.netgate.com/topic/143143/dhcp-leases-are-not-automatically-released/16

                  https://forum.netgate.com/topic/137042/dhcp-service-not-renewing-ip-lease

                  https://forum.netgate.com/topic/166995/remove-dhcp-leases-automatically/15

                  https://forum.netgate.com/topic/46897/dhcp-addresses-not-releasing

                  I am not sure if some particular condition would make the dhcp server not reusing expired ip address.. However, I am 100% sure the DHCP server wasn't releasing IP address when I first wrote this post. I got a new phone and try to connect to the LAN, the phone wouldn't connect to the LAN via wifi. No IP is assigned. Then I started looking into the log and see what happened, and I found that DHCP server is complaining no free lease. So, I looked at the dhcp lease page (the first screenshot on first post) and found that many expired lease stuck in that page and none of those IP address were re-used. This was how I found out the problem.

                  i end up removing all the expired leases , make the pool a bit bigger and voila the new phone connect to the LAN via wifi. So...it's something fishy on the dhcp server...

                  johnpozJ 1 Reply Last reply Reply Quote 0
                  • johnpozJ
                    johnpoz LAYER 8 Global Moderator @sdugoten
                    last edited by

                    @sdugoten while I do recall past posts with sim issue, I don't recall ever being able to duplicate the problem..

                    I would attempt to duplicate it quickly, create a small scope, just a few addresses with really short lease time, and then run through seeing if it will issue an expired lease.

                    You might want to do just a clean flush of the whole leases file, and let it create new file.

                    The leases file is stored here

                    /var/dhcpd/var/db

                    I would shut down dhcp services on all interfaces, then delete the files there will also be a leases~ file and then restart your dhcp services..

                    An intelligent man is sometimes forced to be drunk to spend time with his fools
                    If you get confused: Listen to the Music Play
                    Please don't Chat/PM me for help, unless mod related
                    SG-4860 24.11 | Lab VMs 2.8, 24.11

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      sdugoten @johnpoz
                      last edited by sdugoten

                      @johnpoz said in DHCP server is not releasing expired lease:

                      @sdugoten while I do recall past posts with sim issue, I don't recall ever being able to duplicate the problem..

                      I would attempt to duplicate it quickly, create a small scope, just a few addresses with really short lease time, and then run through seeing if it will issue an expired lease.

                      You might want to do just a clean flush of the whole leases file, and let it create new file.

                      The leases file is stored here

                      /var/dhcpd/var/db

                      I would shut down dhcp services on all interfaces, then delete the files there will also be a leases~ file and then restart your dhcp services..

                      I just stopped the dhcp server service, rename the existing lease file to mydhcpd.leases and then delete all other files. When I restarted the dhcpd service, i saw there is one file owned by root, but not dhcpd. Is that intentional?

                      alt text

                      Before image is like this

                      alt text

                      johnpozJ 1 Reply Last reply Reply Quote 0
                      • G
                        guile
                        last edited by

                        All my files owned by dhcp:

                        -rw-r--r--  1 dhcpd  _dhcp  45947 Jul  9 08:57 dhcpd.leases
                        -rw-r--r--  1 dhcpd  _dhcp  50594 Jul  9 08:48 dhcpd.leases~
                        -rw-r--r--  1 dhcpd  _dhcp      0 May 16 16:28 dhcpd6.leases
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • johnpozJ
                          johnpoz LAYER 8 Global Moderator @sdugoten
                          last edited by

                          @sdugoten yeah I don't think it should be owned by root.

                          [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: ls -la
                          total 35
                          drwxr-xr-x  2 dhcpd  _dhcp      6 Jul  9 06:29 .
                          drwxr-xr-x  4 dhcpd  _dhcp      4 Feb 14  2022 ..
                          -rw-r--r--  1 dhcpd  _dhcp  25151 Jul  9 06:29 dhcpd.leases
                          -rw-r--r--  1 dhcpd  _dhcp  25841 Jul  9 06:29 dhcpd.leases~
                          -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases
                          -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases~
                          [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: 
                          

                          An intelligent man is sometimes forced to be drunk to spend time with his fools
                          If you get confused: Listen to the Music Play
                          Please don't Chat/PM me for help, unless mod related
                          SG-4860 24.11 | Lab VMs 2.8, 24.11

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            sdugoten @johnpoz
                            last edited by

                            @johnpoz said in DHCP server is not releasing expired lease:

                            @sdugoten yeah I don't think it should be owned by root.

                            [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: ls -la
                            total 35
                            drwxr-xr-x  2 dhcpd  _dhcp      6 Jul  9 06:29 .
                            drwxr-xr-x  4 dhcpd  _dhcp      4 Feb 14  2022 ..
                            -rw-r--r--  1 dhcpd  _dhcp  25151 Jul  9 06:29 dhcpd.leases
                            -rw-r--r--  1 dhcpd  _dhcp  25841 Jul  9 06:29 dhcpd.leases~
                            -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases
                            -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases~
                            [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: 
                            

                            This was the steps I did

                            1. Stop the dhcp service in LAN interface under service
                            2. rename the original dhcpd.leases to mydhcpd.leases
                            3. delete all other files
                            4. check the checkbox in dhcpd lan interface to enable it again

                            Files generated as the screenshot above with root ownership.

                            G johnpozJ S 3 Replies Last reply Reply Quote 0
                            • G
                              guile @sdugoten
                              last edited by

                              @sdugoten

                              https://redmine.pfsense.org/issues/4936

                              johnpozJ 1 Reply Last reply Reply Quote 1
                              • johnpozJ
                                johnpoz LAYER 8 Global Moderator @sdugoten
                                last edited by

                                @sdugoten while yeah I see, that doesn't seem right to me..

                                I found this

                                https://redmine.pfsense.org/issues/4936

                                dhcpd sets wrong permissions on leases files

                                An intelligent man is sometimes forced to be drunk to spend time with his fools
                                If you get confused: Listen to the Music Play
                                Please don't Chat/PM me for help, unless mod related
                                SG-4860 24.11 | Lab VMs 2.8, 24.11

                                1 Reply Last reply Reply Quote 0
                                • johnpozJ
                                  johnpoz LAYER 8 Global Moderator @guile
                                  last edited by johnpoz

                                  @guile haha - you beat me too it ;)

                                  Had you looked at these files when you were having the issue - I wonder if was owned by root, and that is why were having no free leases. And then you clearly the old leases fixed the file to have dhcpd owner??

                                  That redmine seems to indicate getting a no leases error when was owned by root..

                                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                                  If you get confused: Listen to the Music Play
                                  Please don't Chat/PM me for help, unless mod related
                                  SG-4860 24.11 | Lab VMs 2.8, 24.11

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    sdugoten @sdugoten
                                    last edited by sdugoten

                                    @sdugoten said in DHCP server is not releasing expired lease:

                                    @johnpoz said in DHCP server is not releasing expired lease:

                                    @sdugoten yeah I don't think it should be owned by root.

                                    [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: ls -la
                                    total 35
                                    drwxr-xr-x  2 dhcpd  _dhcp      6 Jul  9 06:29 .
                                    drwxr-xr-x  4 dhcpd  _dhcp      4 Feb 14  2022 ..
                                    -rw-r--r--  1 dhcpd  _dhcp  25151 Jul  9 06:29 dhcpd.leases
                                    -rw-r--r--  1 dhcpd  _dhcp  25841 Jul  9 06:29 dhcpd.leases~
                                    -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases
                                    -rw-r--r--  1 dhcpd  _dhcp    581 Dec  9  2022 dhcpd6.leases~
                                    [23.05.1-RELEASE][admin@sg4860.local.lan]/var/dhcpd/var/db: 
                                    

                                    This was the steps I did

                                    1. Stop the dhcp service in LAN interface under service
                                    2. rename the original dhcpd.leases to mydhcpd.leases
                                    3. delete all other files
                                    4. check the checkbox in dhcpd lan interface to enable it again

                                    Files generated as the screenshot above with root ownership.

                                    I think that might be the original problem that not re-using ip address, just a wild guess.

                                    However, I can reproduce this problem on Netgate 6100 with firmware 23.05.1-RELEASE (amd64). Even if you try to press this button alt text to remove all leases, it will blank out the lease file, but the ownership of the file "dhcpd.leases~" will change to root. However, the file "dhcpd.leases" still owned by dhcpd though

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.