I have static IPs for all regular hosts on my network. But rather than configure each distinct host locally I have supplied DHCP the complete set of assignments as static reservations. This works, more or less.
I still have to support dynamic DHCP address assignments for random visitors. So I do have dynamic address support enabled. Which leads to my problem. If a device with a static assignment accidentally gets a dynamic address it seems to be able to hold on to it indefinitely by renewing its lease.
Is there any way to cause DHCP to refuse to renew a device's dynamic lease when it has a static reservation, thereby forcing that device to run through the full lease acquisition process?
The dhcp server will automatically issue the correct IP address to the hosts configured for dhcp reservations. If a given host has an address out of the dynamic pool (prior to when you configure the reservation), the dhcp server will not allow that address to be renewed and will instead offer the newly configured reserved address.
Worth noting: The address won’t change until the host attempts to renew the lease which is done For the first time at 1/2 the lease duration or when the interface goes down/up or the system is restarted. So the timing also depends on the length of the lease, but it will eventually get the updated address.
hate to be a grammar prude... but please call it a "dhcp-fixed" or just a reservation...
if you call this static ... what do you call it when you enter an actual ip address on a device?
A device configured with a static lease will not get a dynamic one.
The DHCP server will always offer to specific hosts the designated address you have configured as a static lease.
I guess this is a hypothetical question, not an actual issue. I have never seen any wrong leases, at least not without user's error.
It happens quite often with new devices, if you attach them before configuring a static lease. dnsmasq assigns an address from the dynamic pool and remembers (/etc/leases.dhcp? not in front of my router right now), if you now configure a static lease, the previously assigned/ active dynamic lease retains precedence (until you reboot or stop dnsmasq and remove the dynamic lease from the file).
I just tried it and it didn't happen.
/tmp/dhcp.leases was updated with the new IP address.
Yes. This is the scenario I was trying to describe.
@trendy Are you saying that you tried the scenario @slh described?
Nothing wrong with being a grammar prude. Thanks for pointing out my confusing terminology.
On the OpenWrt side, you can only do the following:
- Use separate ranges for dynamic and static DHCP leases.
- Minimize the lease time.
- Manually force wireless clients to reconnect.
Everything else depends on the implementation and configuration of the DHCP client, which in some cases may not even meet the DHCP specification, so you should take that into consideration when comparing the behavior of different devices.