Community discussions

 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

DHCP pool problem

Thu Sep 13, 2018 8:13 am

Hi everyone,

I have a DHCP server configured in my mikrotik router. I have configured the DHCP server to have an IP pool range of 192.168.0.150-192.168.0.180. There was a point that this pool was given out to to 30 clients. I decided to extend this pool to 192.168.0.190 to accommodate more clients. A number of clients in the old pool were disconnected for a significant amount of time (greater than the lease time) but the dhcp server keeps on giving IP to the new users wfrom 192.168.181 onwards. I was thinking that the server should give the previous vacant IP first before giving the new ones. It seems like that those vacated IP were still reserved. Thank you for the usual support!
 
mkx
Forum Guru
Forum Guru
Posts: 2929
Joined: Thu Mar 03, 2016 10:23 pm

Re: DHCP pool problem

Thu Sep 13, 2018 11:01 am

Concept of dynamic IP addresses says that IP address given to client may change at every lease expiry. Indeed most of DHCP servers tend to allow clients to re-new same IP address (and clients tend to request re-new and include the old IP address) but that is not mandatory. If lease expires then DHCP server has right to forget about last client. If same client later requests lease indicating the same IP address and that IP address is not occupied according to DHCP server's table, then DHCP server will probably re-new lease. If address had been leased to another client, then obviously DHCP server can not re-new the lease but rather assign another IP address.
Strategy of allocating IP addresses from DHCP pool to different clients varies between different DHCP server implementation as well. ROS DHCP server tends to assign IP addresses from top towards bottom. I suspect that if you enlarged DHCP pool by adding addresses at lower part of pool range, you'd see that DHCP server wouldn't assign them until all higher addresses are used up.
BR,
Metod
 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

Re: DHCP pool problem

Thu Sep 13, 2018 11:25 am

Thanks for the explanation. The problem now is that i have configured the lease time to 4 hours. Some of the IP addresses are already in the busy state, i'm figuring that these addresses are already not used then. I have new devices that haven't connected in this router before and it's giving them new IP addresses and not those unsused/busy IP. If this is the case i'll keep on extending my DHCP IP pool and eventually ran out of IP. Is it possible to flush the DHCP server? Is the router storing a list of MAC addresses that it remembers what IP are they associated before?
 
mkx
Forum Guru
Forum Guru
Posts: 2929
Joined: Thu Mar 03, 2016 10:23 pm

Re: DHCP pool problem

Thu Sep 13, 2018 12:32 pm

DHCP server better observe it's own lease time. If you expect many devices to have short lived presence on your LAN, then you can adjust lease time to lower value, e.g. 60 minutes. You can change this value and it will be observed with new leases (and renewals).
BR,
Metod
 
User avatar
k6ccc
Member
Member
Posts: 479
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)

Re: DHCP pool problem

Thu Sep 13, 2018 6:24 pm

From the Wiki:
Lease status:

waiting - un-used static lease
testing - testing whether this address is used or not (only for dynamic leases) by pinging it with timeout of 0.5s
authorizing - waiting for response from radius server
busy - this address is assigned statically to a client or already exists in the network, so it can not be leased
offered - server has offered this lease to a client, but did not receive confirmation from the client
bound - server has received client's confirmation that it accepts offered address, it is using it now and will free the address no later than the lease time
As I read this, if you are seeing IPs with a status of "Busy", it sounds like either a bunch of devices are set to Static IPs in your DHCP range, or there is another DHCP server on your network. Not particularly good. I don't think I have ever seen anything except Waiting and Bound on my network.
RB750Gr3, RB750r2, CRS326-24G-2S (in SwitchOS), CSS326-24G-2S, CSS106-5G-1S, RB260GS
Not sure if I beat them in submission, or they beat me into submission


Jim
 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

Re: DHCP pool problem

Thu Sep 13, 2018 7:12 pm

From the Wiki:
Lease status:

waiting - un-used static lease
testing - testing whether this address is used or not (only for dynamic leases) by pinging it with timeout of 0.5s
authorizing - waiting for response from radius server
busy - this address is assigned statically to a client or already exists in the network, so it can not be leased
offered - server has offered this lease to a client, but did not receive confirmation from the client
bound - server has received client's confirmation that it accepts offered address, it is using it now and will free the address no later than the lease time
As I read this, if you are seeing IPs with a status of "Busy", it sounds like either a bunch of devices are set to Static IPs in your DHCP range, or there is another DHCP server on your network. Not particularly good. I don't think I have ever seen anything except Waiting and Bound on my network.
i'm sorry, i might have mislooked it. no status busy now, everything is bound. my problem is clients keep having the same IP all over again. is it possible to have them take the lowest possible IP?
 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

Re: DHCP pool problem

Thu Sep 13, 2018 7:15 pm

DHCP server better observe it's own lease time. If you expect many devices to have short lived presence on your LAN, then you can adjust lease time to lower value, e.g. 60 minutes. You can change this value and it will be observed with new leases (and renewals).
i set the lease time to 60 minutes as you said but i'm still having the same issue. Is it possible for the dhcp server to give the lowest available IP to a renewing client?

as you can see here, a lot of IPs were skipped.
https://ibb.co/kdqzVU
 
mkx
Forum Guru
Forum Guru
Posts: 2929
Joined: Thu Mar 03, 2016 10:23 pm

Re: DHCP pool problem

Thu Sep 13, 2018 7:23 pm

Wiki manual about DHCP server is not entirely consistent. Slightly before text, quoted by @k6ccc, it is also written:
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
(emphasis is mine). Which would give the "busy" leases entirely different reason for being busy. However my own observation does not support quotation just above. In one of my LANs with configured lease-time=1h I can see a static lease:
    address=192.168.13.42 mac-address=00:E1:00:86:1E:34
     client-id="1:0:e1:0:86:1e:34" address-lists="" server=defconf
     dhcp-option="" status=waiting last-seen=1w3d20h30m23s
.
So do as @k6ccc already recomended: check if there's another DHCP server active in the same L2 network or if excessive number of devices are statically configured with IP addresses.

BTW, you may also check the setting of /ip dhcp-server config attribute store-leases-disk. If DHCP server assigned many leases and then RB got rebooted, then it may happened that those leases were not stored to disk and info about that is lost ... devices rightfully use leased addresses until lease expiry (they don't notice nor care if DHCP server suffered from amnesia) while DHCP server sees addresses being used without it's knowledge (hence busy).
BR,
Metod
 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

Re: DHCP pool problem

Thu Sep 13, 2018 7:43 pm

Wiki manual about DHCP server is not entirely consistent. Slightly before text, quoted by @k6ccc, it is also written:
A client may free the leased address. The dynamic lease is removed, and the allocated address is returned to the address pool. But the static lease becomes busy until the client reacquires the address.
(emphasis is mine). Which would give the "busy" leases entirely different reason for being busy. However my own observation does not support quotation just above. In one of my LANs with configured lease-time=1h I can see a static lease:
    address=192.168.13.42 mac-address=00:E1:00:86:1E:34
     client-id="1:0:e1:0:86:1e:34" address-lists="" server=defconf
     dhcp-option="" status=waiting last-seen=1w3d20h30m23s
.
So do as @k6ccc already recomended: check if there's another DHCP server active in the same L2 network or if excessive number of devices are statically configured with IP addresses.

BTW, you may also check the setting of /ip dhcp-server config attribute store-leases-disk. If DHCP server assigned many leases and then RB got rebooted, then it may happened that those leases were not stored to disk and info about that is lost ... devices rightfully use leased addresses until lease expiry (they don't notice nor care if DHCP server suffered from amnesia) while DHCP server sees addresses being used without it's knowledge (hence busy).
right now i dont have a busy state in my IPs. what's the command to see this status?
address=192.168.13.42 mac-address=00:E1:00:86:1E:34
client-id="1:0:e1:0:86:1e:34" address-lists="" server=defconf
dhcp-option="" status=waiting last-seen=1w3d20h30m23s
 
User avatar
k6ccc
Member
Member
Posts: 479
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)

Re: DHCP pool problem

Thu Sep 13, 2018 7:47 pm

is it possible to have them take the lowest possible IP?
No. ROS assigns IP addresses from the top of the pool. You have no control of that.

My recommendation is that if you have devices that you want to have a specific address, let them connect (so they show up in the DHCP Leases list), and then change them to static. If you want them to have a different address, you can set it. The address will remain as assigned until the next time the client renews the lease at which time it will get the address that you set for a static DHCP assignment. On both of my routers, the DHCP pool is only 10 IPs, however essentially every device that routinely connects (computers, IP cameras, phones, etc) all have a static reservation that is outside of the DHCP pool of addresses. For example, on the LAN that is used by my WiFi cameras, the DHCP pool is 192.168.106.100 - 192.168.106.109, but the cameras all have DHCP static reservations of 192.168.106.07x - .08x. The only time the 192.168.106.10x addresses are used is with a new camera when it connects for the first time (provided I was being lazy and did not build the static reservation before the camera connected.
RB750Gr3, RB750r2, CRS326-24G-2S (in SwitchOS), CSS326-24G-2S, CSS106-5G-1S, RB260GS
Not sure if I beat them in submission, or they beat me into submission


Jim
 
User avatar
k6ccc
Member
Member
Posts: 479
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)

Re: DHCP pool problem

Thu Sep 13, 2018 7:52 pm

right now i dont have a busy state in my IPs. what's the command to see this status?
address=192.168.13.42 mac-address=00:E1:00:86:1E:34
client-id="1:0:e1:0:86:1e:34" address-lists="" server=defconf
dhcp-option="" status=waiting last-seen=1w3d20h30m23s
I normally use WinBox and there it's easy. Just select the Leases tab. I don't remember the CLI command for it.
RB750Gr3, RB750r2, CRS326-24G-2S (in SwitchOS), CSS326-24G-2S, CSS106-5G-1S, RB260GS
Not sure if I beat them in submission, or they beat me into submission


Jim
 
freshfrench
just joined
Topic Author
Posts: 14
Joined: Fri Dec 08, 2017 2:15 am

Re: DHCP pool problem

Thu Sep 13, 2018 8:04 pm

is it possible to have them take the lowest possible IP?
No. ROS assigns IP addresses from the top of the pool. You have no control of that.

My recommendation is that if you have devices that you want to have a specific address, let them connect (so they show up in the DHCP Leases list), and then change them to static. If you want them to have a different address, you can set it. The address will remain as assigned until the next time the client renews the lease at which time it will get the address that you set for a static DHCP assignment. On both of my routers, the DHCP pool is only 10 IPs, however essentially every device that routinely connects (computers, IP cameras, phones, etc) all have a static reservation that is outside of the DHCP pool of addresses. For example, on the LAN that is used by my WiFi cameras, the DHCP pool is 192.168.106.100 - 192.168.106.109, but the cameras all have DHCP static reservations of 192.168.106.07x - .08x. The only time the 192.168.106.10x addresses are used is with a new camera when it connects for the first time (provided I was being lazy and did not build the static reservation before the camera connected.
ok so that explains it. i'm just a bit triggered that IP addresses are skipped instead of giving it to clients that are renewing. And when the last IP of the IP pool has been given, the router gives an IP address outside of the pool instead of giving the available IPs. Is there a way to clean this up or flush the dhcp server, aside from restoring it to default, from remembering these mac addresses previously associated with the IPs? thank you for taking the time to explain.
 
mkx
Forum Guru
Forum Guru
Posts: 2929
Joined: Thu Mar 03, 2016 10:23 pm

Re: DHCP pool problem

Thu Sep 13, 2018 9:50 pm

While webfig on 6.37 doesn't show status, CLI comand to check lease details is
/ip dhcp-server lease print detail
.
You can remove lease ussing command /ip dhcp-server lease remove ... or at least try to do it. I'm pretty sure you can remove static lease in state waiting, but I don't expect you can do it for dynamic leases with status bound. Reality might prove me wrong.
BR,
Metod

Who is online

Users browsing this forum: MSN [Bot] and 38 guests