When a client requests an IP address under DHCP, the dhcpd daemon assigns an address from a pool of IP addresses stored in the /etc/dhcpd.conf file. Before dhcpd grants the client a lease on this address, it records the details of the lease in the leases database, a free-form ASCII file (/var/state/dhcp/dhcpd.leases) that contains a series of lease declarations. The daemon makes sure that the contents of thefile are flushed to disk, ensuring that, even in the event of a system crash, dhcpd will not forget about a lease that it hasassigned. On startup, after reading the dhcpd.conf file, dhcpd also reads the saved dhcpd.leases file.
Every time a lease is acquired, renewed or released, its new value is recorded atthe end of the lease file. So if more than one declaration appearsfor a given lease, the last one in the file is the current one.
There is no lease database when you first install dhcpd but the daemon will not start without one, so before you can offer DHCP services, you have to create an empty file called /var/state/dhcpd/dhcpd.leases.
Lease descriptions are stored in a format that is parsed by the samerecursive descent parser used to read /etc/dhcpd.conf files. Currently, the only declaration that is used in the dhcpd.leases file is the lease declaration.
The weekday is present to make it easy for you to tell when alease expires: it's specified as a number from zero to six, with zerobeing Sunday. The day of week is ignored on input. The year isspecified with the century, so it should generally be four digitsexcept for really long leases. The month is specified as a numberstarting with 1 for January. The day of the month is likewisespecified starting with 1. The hour is a number between 0 and 23, theminute a number between 0 and 59, and the second also a number between0 and 59. Lease times are specified in UCT, not in the local time zone.
DHCP leases can be assigned almost any length from zero seconds toinfinity. What lease length makes sense for any given subnet, or forany given installation, will vary depending on the kinds of hostsbeing served. For example, in an office environment where you add or remove systems infrequently, you might allow monthly leases whereas in a final test environment on a manufacturing floor, you might want to restrict leases to 30 minutes or so.
The DHCP server may determine that a lease has been misused in someway, either because a client that has been assigned a lease NAKs it,or because the server's own attempt to see if an address is in useprior to reusing it reveals that the address is in fact already inuse. In that case, the abandoned statement is used toindicate that the lease should not be reassigned, like this:
Abandoned leases are reclaimed automatically. When a client asks fora new address, and the server finds that there are no new addresses,it checks to see if there are any abandoned leases, and allocates theleast recently abandoned lease. The standard mechanisms for checkingfor lease address conflicts are still followed, so if the abandonedlease's IP address is still in use, it will be re-abandoned.
If a client requests an abandoned address, the server assumesthat the reason the address was abandoned was that the lease file wascorrupted, and that the client is the machine that responded when thelease was probed, causing it to be abandoned. In that case, theaddress is immediately assigned to the client.
Here is the behavior that startles me: Many of devices show up in both, fixed and dynamic leases. Some of them show up twice under dynamic lease, the first time without MAC address. See example of one device highlightd in the screenshot below. They can be pinged via their latest dynamically assigned address.
That was my expectation, which is why I was surprised to see new dynamic leases. I can live with the duplicate entries, entries without MAC and the fact that ipfire assigns the dynamic rather than the fixed addresses are the puzzlers. From a recent backup, the file:
/var/ipfire/dhcp/fixleases contains all entries of my GREEN network. None for BLUE.
/var/ipfire/dhcp/dhcpd.conf contains subnet definitions for GREEN and BLUE plus entries for fixed leases on GREEN.
Yes, they are showing in the WUI as shown in the screenshot. History of browser deletes with every shutdown, so the information is fresh and not from cache. Clearing one hour of cache in the browser and reloading the WUI rendered the same result.
All fixed leases are written into /var/ipfire/dhcp/dhcp.conf
If you have a dynamic section but no fixed leases in the conf file then it is likely that you have fixed leases for the Blue subnet defined in the Current Fixed Leases section that are not enabled.
If you have a client that is in the Fixed Lease section but not enabled then dhcp will provide it with a lease from the defined dynamic range. You will then see it in your Current Fixed Lease section and also in the Current Dynamic Leases section.
Might this be an unwanted, undocumented feature (bug)? I still need to check tonight that this edit caused the desired effect of fixing IP addresses and will report results. If yes, should I file a bug report?
I believe as soon as the client disconnects and reconnects to the network it will go through the DHCP process again. At that point they will receive the newly assigned static address. If they try to renew the lease I think the DHCP server will refuse and assign them the static IP address too.
This has worked for me in the past. After you turn off DHCP for that subnet, wait about 5 minutes, then turn it back on. When you turn it back on, all your previous settings are still there so it's not as painful as it seems.
Looks like they patched that out?
We read your comment and decided to try it. We were joking that only the new leases would get the shortened lease time. We thought that was a hysterical idea. Then it turns out that's what happened. A lot less funny than we thought...
is there any development going on for this issue? Manually changing dhcp leases to 30 min at the eod is not the ultimate solution. I hope there would be a select and delete option somewhere for removing dhcp leases.
Meraki Dashboard used to have that option under Monitor -> Appliance Status -> Tools, but somehow they took that away. I've put in feature request for many times, but I still do not see that option. I've done set lease time, created and removed dhcp reservation scope, but it did not work like the way I want. This's very annoyed.
It seemed to work at first. All client DHCP leases were removed from the dash... except they some came back with the original entries. All of the phones are still advertising that their lease time will expire in 20+ hours. Effectively maintaining the lease time they originally had.
Nice work-around S_Tech. I would still very much like to see a simple way to remove a lease, such as a column with an "x" to the right of each entry on the DHCP Lease table, and/or a clear all type option. Even my cheap little TP-Link router has this feature. Where is that wish button?
I just had the same issue. Rebooting and turning DHCP off for 5 minutes did NOT clear the DHCP leases. What did work was expanding the DHCP Reservation range temporarily and it cleared the DHCP leases in the Reserved range like the example below.
I eventually managed to configure all my needed leases (about 60 IPs) but i noticed that some devices at their reboot occasionally use old leases despite static one configured.
an example below:
broadlinkIR device with configured IP 192.168.199.20
this is just an example.
very same issue is occurring with 2 additional RTSP cameras which at each reboot change their IP between old lease and static ones and thus requiring me to update HA configuration each time. Very annoying.
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
for example, broadlink takes .119 instead of .20 and LAN camera takes .103 instead of .34.
probably, these IPs were valid with old firmware.
Broadlink was also reset to factory settings so theoretically should not have any remember of old lease.
I'm relatively new to Linux and Ubuntu, so please bear with me. I'm setting up a Ubuntu 18.04 LTS VM that will act as a mail relay via postfix. I have that installed, and have configured those settings to match the old existing relay server that was set up years ago, at least as much as I can determine. My issues is, the connection from this new relay server is timing out, which I can see in the /var/log/mail.log file. This server is set up to obtain an IP via DHCP because of the way our network is set up. I work for a group that is affiliated with a university, but we're not directly part of the IT staff, so my group has their own IT department, of which I'm a part. In order to get anything on the University's network, we have to register the MAC address of the device, then once that registration is complete with the uni, they assign an IP address and the device gets a lease.
What I can't figure out is two-fold: first, how to look up what my lease information is. Second, in conjunction with that, how I can see what DNS servers are included with that lease. I've used a number of commands to try and look that information up, or glean it from Ubuntu in some way, but to no avail. I also have the Ubuntu desktop installed, as that was something the previous mail relay server had, just so I could be as 1:1 with my setup as possible, and I can't find any info via the Network section of the system settings either. I looked through for anything with 'dhcp' or 'dns' in the list, but couldn't seem to find a command I could throw at it to determine the answer to my question.
The other curious thing is, my network interface is labeled 'ens160' instead of 'eth0', which I thought was odd. In any event, I'm trying to determine what my DHCP and DNS info is, because I can ping some hostnames inside and outside the network, but I might be missing some internal DNS server entries, in which case, I'll need to know how to add those, but I also want to make sure I can clearly see what my setup is. Unfortunately, ifconfig doesn't return much more than the IP, MAC, and interface name info. Anyway, sorry for the novella, but I'm just trying to figure out how to see the full networking details on my new server, so I can better troubleshoot the issue at hand.
c80f0f1006