24

I have generally seen that DHCP lease times are quite long (a day plus) on most defaults. I have a client that seems to have the following problem. They have a DHCP server in a router that is near-saturation (say in a normal work day 80-85% of the potential IPs are used). Occasionally they restart their router. When that happens it seems that the the router loses its table of assigned IPs, so it assigns IPs anew (of course).

The problem is that quite often there is a client on the LAN which has the IP already and is going to hold it for a day (the current timeout length), causing an IP conflict and connectivity issues for those two machines.

The obvious solution is to make a very short lease time, but since I'm only a hobbyist when it comes to networking, there may be more to DHCP that I don't understand.

Is the above a reasonable evaluation of the situation (at least with lower-end equipment) and does a lower lease time (say a half-hour) make sense in this case?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
Yishai
  • 708
  • 1
  • 6
  • 15

8 Answers8

25

You should consider replacing the DHCP server, as it is obviously broken. DHCP servers should keep lease information between restarts and preferably also probe addresses before releasing them into the pool to avoid address duplication.

If that is not an option you can drop the lease length. As long as the DHCP server can handle the churn it should work, but short leases will cause a small increase the amount of broadcast traffic on your network.

Short leases are primarily a problem when you have clients disconnecting and reconnecting a lot, for example in WiFi networks. Very short leases (less than 1 minute) can cause weird problems with some DHCP clients that have time-outs longer than the lease.

pehrs
  • 8,749
  • 29
  • 46
  • Regarding short lease times: I've been noticing that certain Android devices (for example an Amazon Fire 8 HD, but not limited to that one) do disconnect when the lease times out. So if I have a lease time of 10 minutes, WiFi will seem to disconnect and reconnect every 10 minutes (ie video streams will drop and the video player app close). Assigning a static IP to those devices fixes the issue, increasing the lease time would also ease that issue. – Daniel F Nov 23 '16 at 22:54
  • Regarding the Android devices in the previous comment, those are running Android 5. – Daniel F Nov 23 '16 at 23:08
13

Fix the real problem. DHCP servers should remember leases between restarts and should ping test IPs before handing them out (to make reasonably sure they aren't already in use).

Windows Server comes with a DHCP server. Any *nix platform can run ISC DHCPd. Both are pretty good choices and will easily accomplish the above requirements.

We have DHCP leases set to 8 days for IPv4, and 2 weeks for IPv6. Whatever you set, remember clients will renew after 1/2 the time, so if you set it to 8 hours, it'll renew every 4 hours (continuing with double declining time upon failed requests).

Chris S
  • 77,337
  • 11
  • 120
  • 212
7

Your routers DHCP server implementation may be able to do "DHCP collision detect". Check this out and enable it if possible. This is the easiest fix.

Shorter lease-times will definitely help but are not a 100% guarantee. I would not go below 1 hour though. In my experience many network-programs don't really like it the computer re-acquires DHCP while the program is running (e.g. Outlook2003 is notorious for this, 2007 seems better behaved). Doing it every 5 minutes may be quite noticable to the users.

If the DHCP scope is large enough for all computers on-site and the majority of those computers is fixed on-site it may be feasible to assign the regular systems a fixed ip-address through DHCP reservation, leaving only a very small pool of dynamically assigned addresses for guests and/or laptops that are infrequent in the office. The reserved addresses will not be subject to collisions. Of course: Someone has to maintain that reservation list......

If you have another DHCP server (Windows/Linux or another router) on your WAN that is able to do collision detect you may consider adding this LAN as an additional DHCP scope there and reconfigure the site-router to forward DHCP to this one.

If all else fails you will have to setup a separate DHCP server. For up to about 200 users you don't really need a big Windows server or a Linux box. You can get away with something like TFTPD32 which is free, easy to setup and will do collision detect as well. (And it will run on a desktop OS if costs are an issue. If you happen to have a PC lying around that can be left "always on"). (And, see previous paragraph, this can be located on another site.)

Tonny
  • 6,252
  • 1
  • 17
  • 31
  • 1
    Question: Shouldn't the DHCP address get renewed before the lease expires? If Outlook is running, then the system should be renewing the address and not losing it, right? – user541686 Sep 17 '17 at 23:03
5

A lease time of 30 minutes will be fine for a few hundred of clients. If you have under 100 clients you can use 5 or 10 minutes.

Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
  • My main concern is some cheap IOT devices or printer appliance clients wearing out their EEPROM faster with short leases. Has anybody experienced this before? Or is the lease information commonly only held in RAM on the client? – user643011 May 04 '22 at 11:45
  • 1
    It should be saved in RAM. E.g. OpenWRT is saving the lease file in ramfs, both for the DHCP client and for server. – Mircea Vutcovici May 04 '22 at 20:00
5

The only real issue I would consider is server load. Since DHCP is a relatively light service compared to current processor/network power, that consideration is becoming much less important.

This is of course all relative to the size of your network. A class C full of clients is one thing, 5 class As is a completely different beast.

Try setting it to the 30 minutes you mentioned, and see how your router reacts as far as processor load.

More reading available here: http://www.dhcp-handbook.com/dhcp_faq.html (Look at Question 35)

Hyppy
  • 15,458
  • 1
  • 37
  • 59
3

I agree on Stefan, the correct lease time depends on a few parameters. How many users, how long the clients stay generally connected, what class network you have, how powerfull is your router. In my case many people walk in and out the clubhouse. At the most busiest times I see 100 simultanious connections. Every day I'm guessing that 700-1000 people will visit.

Our ISP provided a cheap home-use router that doesn't support a good DHCP server with shorter lease times < 1 day so that whould mean a large DHCP pool with in turn the router can't handle. The lease table would be too large to maintain next to the other functions the router has so the DORA functions fail and clients will asign themselves an APIPA address. Since the netwerk doesn't contain a server of any kind I bought a cheap router (tp-link WR841n) that supports a good DHCP server with options to give clients, routing / DNS specification and shorter lease times.

I only enabled this router to act as dedicated DHCP server and gave clients a 30 minutes lease time. After the 30 minutes, the DHCP server will contact the client if it's still there, if not it will release the IP-address if still present it will reassign 30 minutes to the client lease. Client will keep the same IP-address. DHCP range is set within the Private Address Range with 254 simultanious leases max. (bases on the total max. connections of the AP's). This works great for my case.

Restarting a DHCP server and flushing its table is not a good idea, unless you make sure to disconnect all the clients from your network first (disable WiFi AP's). Give it a minute at least to make sure all clients are disconnected. Then start up the network in the following order and wait until fully started and connected: router, DHCP server, Wifi Access Points.

Nemo
  • 259
  • 1
  • 13
IT freak
  • 31
  • 2
2

Wouldn't a better solution be to fix the problem with the DHCP server or replace it?

joeqwerty
  • 108,377
  • 6
  • 80
  • 171
2

I have had several cases where users are not the same for more than half a day, i.e. restaurants guest houses and hotels, if they have lease over few hours or an day one needs enormous ip pool in order not to run out and have clients with ip assignment that are long gone. But for regular network where there are the same devices an users all the time 3 days is fine.

Stefan

StefanB
  • 21
  • 1